|
|
@@ -5,7 +5,6 @@
|
|
|
#include <input/input.h>
|
|
|
#include <notification/notification.h>
|
|
|
#include <notification/notification_messages.h>
|
|
|
-#include <gui/canvas_i.h>
|
|
|
#include "bomberduck_icons.h"
|
|
|
#include <dolphin/dolphin.h>
|
|
|
|
|
|
@@ -21,7 +20,6 @@ int min(int a, int b) {
|
|
|
#define WorldSizeY 6
|
|
|
#define BombRange 1
|
|
|
|
|
|
-
|
|
|
typedef struct {
|
|
|
FuriMutex* mutex;
|
|
|
} BomberState;
|
|
|
@@ -105,7 +103,7 @@ void init() {
|
|
|
}
|
|
|
}
|
|
|
world.running = 1;
|
|
|
- world.bombs_count =0;
|
|
|
+ world.bombs_count = 0;
|
|
|
vibration = false;
|
|
|
for(int j = max(0, player.y - BombRange); j < min(WorldSizeY, player.y + BombRange + 1); j++) {
|
|
|
world.matrix[j][player.x] = 0;
|
|
|
@@ -191,7 +189,6 @@ static const NotificationSequence vibr1 = {
|
|
|
NULL,
|
|
|
};
|
|
|
|
|
|
-
|
|
|
void intToStr(int num, char* str) {
|
|
|
int i = 0, sign = 0;
|
|
|
|
|
|
@@ -344,7 +341,7 @@ static void draw_callback(Canvas* canvas, void* ctx) {
|
|
|
if(world.player->x == world.endx && world.player->y == world.endy) {
|
|
|
if(world.level == 20) {
|
|
|
canvas_draw_str(canvas, 30, 35, "You win!");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
canvas_draw_str(canvas, 30, 35, "Next level!");
|
|
|
char str[20];
|
|
|
intToStr(world.level, str);
|
|
|
@@ -385,7 +382,7 @@ int32_t bomberduck_app(void* p) {
|
|
|
return 255;
|
|
|
}
|
|
|
|
|
|
- DOLPHIN_DEED(DolphinDeedPluginGameStart);
|
|
|
+ dolphin_deed(DolphinDeedPluginGameStart);
|
|
|
// Создаем новый view port
|
|
|
ViewPort* view_port = view_port_alloc();
|
|
|
// Создаем callback отрисовки, без контекста
|
|
|
@@ -427,24 +424,24 @@ int32_t bomberduck_app(void* p) {
|
|
|
if(world.running) {
|
|
|
if(event.key == InputKeyUp) {
|
|
|
if(world.player->y > 0 &&
|
|
|
- world.matrix[world.player->y - 1][world.player->x] == 0)
|
|
|
+ world.matrix[world.player->y - 1][world.player->x] == 0)
|
|
|
world.player->y--;
|
|
|
}
|
|
|
if(event.key == InputKeyDown) {
|
|
|
if(world.player->y < WorldSizeY - 1 &&
|
|
|
- world.matrix[world.player->y + 1][world.player->x] == 0)
|
|
|
+ world.matrix[world.player->y + 1][world.player->x] == 0)
|
|
|
world.player->y++;
|
|
|
}
|
|
|
if(event.key == InputKeyLeft) {
|
|
|
world.player->side = 0;
|
|
|
if(world.player->x > 0 &&
|
|
|
- world.matrix[world.player->y][world.player->x - 1] == 0)
|
|
|
+ world.matrix[world.player->y][world.player->x - 1] == 0)
|
|
|
world.player->x--;
|
|
|
}
|
|
|
if(event.key == InputKeyRight) {
|
|
|
world.player->side = 1;
|
|
|
if(world.player->x < WorldSizeX - 1 &&
|
|
|
- world.matrix[world.player->y][world.player->x + 1] == 0)
|
|
|
+ world.matrix[world.player->y][world.player->x + 1] == 0)
|
|
|
world.player->x++;
|
|
|
}
|
|
|
}
|
|
|
@@ -459,8 +456,8 @@ int32_t bomberduck_app(void* p) {
|
|
|
notification_message(notification, &end);
|
|
|
world.running = 0;
|
|
|
world.level += 1;
|
|
|
- if(world.level%5==0){
|
|
|
- DOLPHIN_DEED(DolphinDeedPluginGameWin);
|
|
|
+ if(world.level % 5 == 0) {
|
|
|
+ dolphin_deed(DolphinDeedPluginGameWin);
|
|
|
}
|
|
|
}
|
|
|
for(int i = 0; i < world.bombs_count; i++) {
|
|
|
@@ -524,13 +521,18 @@ int32_t bomberduck_app(void* p) {
|
|
|
world.bombs[j] = world.bombs[j + 1];
|
|
|
}
|
|
|
world.bombs_count--;
|
|
|
- } else if(furi_get_tick() - world.bombs[i].planted > (unsigned long)max((3000 - world.level * 150)*2/3, 666)&&world.matrix[world.bombs[i].y][world.bombs[i].x]!=5) {
|
|
|
- world.matrix[world.bombs[i].y][world.bombs[i].x] = 5;
|
|
|
- vibration=true;
|
|
|
-
|
|
|
- } else if(furi_get_tick() - world.bombs[i].planted > (unsigned long)max((3000 - world.level * 150)/3, 333)&& world.matrix[world.bombs[i].y][world.bombs[i].x]!=4) {
|
|
|
- world.matrix[world.bombs[i].y][world.bombs[i].x] = 4;
|
|
|
-
|
|
|
+ } else if(
|
|
|
+ furi_get_tick() - world.bombs[i].planted >
|
|
|
+ (unsigned long)max((3000 - world.level * 150) * 2 / 3, 666) &&
|
|
|
+ world.matrix[world.bombs[i].y][world.bombs[i].x] != 5) {
|
|
|
+ world.matrix[world.bombs[i].y][world.bombs[i].x] = 5;
|
|
|
+ vibration = true;
|
|
|
+
|
|
|
+ } else if(
|
|
|
+ furi_get_tick() - world.bombs[i].planted >
|
|
|
+ (unsigned long)max((3000 - world.level * 150) / 3, 333) &&
|
|
|
+ world.matrix[world.bombs[i].y][world.bombs[i].x] != 4) {
|
|
|
+ world.matrix[world.bombs[i].y][world.bombs[i].x] = 4;
|
|
|
}
|
|
|
}
|
|
|
for(int e = 0; e < world.enemies_count; e++) {
|
|
|
@@ -618,13 +620,13 @@ int32_t bomberduck_app(void* p) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(vibration){
|
|
|
+ if(vibration) {
|
|
|
notification_message(notification, &vibr1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- view_port_update(view_port);
|
|
|
furi_mutex_release(bomber_state->mutex);
|
|
|
+ view_port_update(view_port);
|
|
|
}
|
|
|
|
|
|
// Return to normal backlight settings
|