|
@@ -3,6 +3,7 @@
|
|
|
#include <notification/notification.h>
|
|
#include <notification/notification.h>
|
|
|
#include <notification/notification_messages.h>
|
|
#include <notification/notification_messages.h>
|
|
|
#include <storage/storage.h>
|
|
#include <storage/storage.h>
|
|
|
|
|
+#include <dolphin/dolphin.h>
|
|
|
|
|
|
|
|
#include "sandbox.h"
|
|
#include "sandbox.h"
|
|
|
|
|
|
|
@@ -46,10 +47,7 @@ static moving_cell_t moving_cell;
|
|
|
static uint8_t loaded_saving_ticks;
|
|
static uint8_t loaded_saving_ticks;
|
|
|
static uint8_t popup_menu_selected_item;
|
|
static uint8_t popup_menu_selected_item;
|
|
|
|
|
|
|
|
-static const char* popup_menu_strings[] = {
|
|
|
|
|
- "Continue",
|
|
|
|
|
- "Reset"
|
|
|
|
|
-};
|
|
|
|
|
|
|
+static const char* popup_menu_strings[] = {"Continue", "Reset"};
|
|
|
|
|
|
|
|
static uint8_t keys[KEY_STACK_SIZE];
|
|
static uint8_t keys[KEY_STACK_SIZE];
|
|
|
static uint8_t key_stack_head = 0;
|
|
static uint8_t key_stack_head = 0;
|
|
@@ -263,27 +261,25 @@ static void game_tick() {
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case ScenePopup:
|
|
case ScenePopup:
|
|
|
- if (!key_stack_is_empty()) {
|
|
|
|
|
- switch(key_stack_pop())
|
|
|
|
|
- {
|
|
|
|
|
- case DirectionDown:
|
|
|
|
|
- popup_menu_selected_item++;
|
|
|
|
|
- popup_menu_selected_item = popup_menu_selected_item % POPUP_MENU_ITEMS;
|
|
|
|
|
- break;
|
|
|
|
|
- case DirectionUp:
|
|
|
|
|
- popup_menu_selected_item--;
|
|
|
|
|
- popup_menu_selected_item = popup_menu_selected_item % POPUP_MENU_ITEMS;
|
|
|
|
|
- break;
|
|
|
|
|
- case DirectionNone:
|
|
|
|
|
- if (popup_menu_selected_item == 0) {
|
|
|
|
|
- game_state.scene = ScenePlay;
|
|
|
|
|
- notification_message(notification, &sequence_single_vibro);
|
|
|
|
|
- }
|
|
|
|
|
- else if (popup_menu_selected_item == 1) {
|
|
|
|
|
- notification_message(notification, &sequence_single_vibro);
|
|
|
|
|
- game_init();
|
|
|
|
|
- }
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ if(!key_stack_is_empty()) {
|
|
|
|
|
+ switch(key_stack_pop()) {
|
|
|
|
|
+ case DirectionDown:
|
|
|
|
|
+ popup_menu_selected_item++;
|
|
|
|
|
+ popup_menu_selected_item = popup_menu_selected_item % POPUP_MENU_ITEMS;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case DirectionUp:
|
|
|
|
|
+ popup_menu_selected_item--;
|
|
|
|
|
+ popup_menu_selected_item = popup_menu_selected_item % POPUP_MENU_ITEMS;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case DirectionNone:
|
|
|
|
|
+ if(popup_menu_selected_item == 0) {
|
|
|
|
|
+ game_state.scene = ScenePlay;
|
|
|
|
|
+ notification_message(notification, &sequence_single_vibro);
|
|
|
|
|
+ } else if(popup_menu_selected_item == 1) {
|
|
|
|
|
+ notification_message(notification, &sequence_single_vibro);
|
|
|
|
|
+ game_init();
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
@@ -358,12 +354,13 @@ static void render_callback(Canvas* const canvas) {
|
|
|
canvas_set_color(canvas, ColorWhite);
|
|
canvas_set_color(canvas, ColorWhite);
|
|
|
canvas_draw_box(canvas, 0, 0, 128, 64);
|
|
canvas_draw_box(canvas, 0, 0, 128, 64);
|
|
|
|
|
|
|
|
- if(game_state.scene == ScenePlay || game_state.scene == SceneWin || game_state.scene == ScenePopup) {
|
|
|
|
|
|
|
+ if(game_state.scene == ScenePlay || game_state.scene == SceneWin ||
|
|
|
|
|
+ game_state.scene == ScenePopup) {
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
canvas_set_color(canvas, ColorBlack);
|
|
|
board_draw(canvas);
|
|
board_draw(canvas);
|
|
|
info_draw(canvas);
|
|
info_draw(canvas);
|
|
|
|
|
|
|
|
- if (loaded_saving_ticks && game_state.scene != ScenePopup) {
|
|
|
|
|
|
|
+ if(loaded_saving_ticks && game_state.scene != ScenePopup) {
|
|
|
canvas_set_color(canvas, ColorWhite);
|
|
canvas_set_color(canvas, ColorWhite);
|
|
|
canvas_draw_rbox(canvas, 20, 24, 88, 16, 4);
|
|
canvas_draw_rbox(canvas, 20, 24, 88, 16, 4);
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
canvas_set_color(canvas, ColorBlack);
|
|
@@ -381,23 +378,23 @@ static void render_callback(Canvas* const canvas) {
|
|
|
canvas_draw_box(canvas, 10, 23, 108, 18);
|
|
canvas_draw_box(canvas, 10, 23, 108, 18);
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
canvas_set_color(canvas, ColorBlack);
|
|
|
canvas_draw_xbm(canvas, 14, 27, 100, 10, pic_puzzled);
|
|
canvas_draw_xbm(canvas, 14, 27, 100, 10, pic_puzzled);
|
|
|
- }
|
|
|
|
|
- else if (game_state.scene == ScenePopup) {
|
|
|
|
|
- gray_screen(canvas);
|
|
|
|
|
- canvas_set_color(canvas, ColorWhite);
|
|
|
|
|
- canvas_draw_rbox(canvas, 28, 16, 72, 32, 4);
|
|
|
|
|
- canvas_set_color(canvas, ColorBlack);
|
|
|
|
|
- canvas_draw_rframe(canvas, 28, 16, 72, 32, 4);
|
|
|
|
|
|
|
+ } else if(game_state.scene == ScenePopup) {
|
|
|
|
|
+ gray_screen(canvas);
|
|
|
|
|
+ canvas_set_color(canvas, ColorWhite);
|
|
|
|
|
+ canvas_draw_rbox(canvas, 28, 16, 72, 32, 4);
|
|
|
|
|
+ canvas_set_color(canvas, ColorBlack);
|
|
|
|
|
+ canvas_draw_rframe(canvas, 28, 16, 72, 32, 4);
|
|
|
|
|
|
|
|
- for(int i=0; i < POPUP_MENU_ITEMS; i++) {
|
|
|
|
|
- if ( i == popup_menu_selected_item) {
|
|
|
|
|
- canvas_set_color(canvas, ColorBlack);
|
|
|
|
|
- canvas_draw_box(canvas, 34, 20 + 12 * i, 60, 12);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- canvas_set_color(canvas, i == popup_menu_selected_item ? ColorWhite : ColorBlack);
|
|
|
|
|
- canvas_draw_str_aligned(canvas, 64, 26 + 12 * i, AlignCenter, AlignCenter, popup_menu_strings[i]);
|
|
|
|
|
|
|
+ for(int i = 0; i < POPUP_MENU_ITEMS; i++) {
|
|
|
|
|
+ if(i == popup_menu_selected_item) {
|
|
|
|
|
+ canvas_set_color(canvas, ColorBlack);
|
|
|
|
|
+ canvas_draw_box(canvas, 34, 20 + 12 * i, 60, 12);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ canvas_set_color(canvas, i == popup_menu_selected_item ? ColorWhite : ColorBlack);
|
|
|
|
|
+ canvas_draw_str_aligned(
|
|
|
|
|
+ canvas, 64, 26 + 12 * i, AlignCenter, AlignCenter, popup_menu_strings[i]);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -418,22 +415,22 @@ static void game_event_handler(GameEvent const event) {
|
|
|
key_stack_push(DirectionLeft);
|
|
key_stack_push(DirectionLeft);
|
|
|
break;
|
|
break;
|
|
|
case InputKeyOk:
|
|
case InputKeyOk:
|
|
|
- if (game_state.scene == ScenePlay) {
|
|
|
|
|
|
|
+ if(game_state.scene == ScenePlay) {
|
|
|
game_state.scene = ScenePopup;
|
|
game_state.scene = ScenePopup;
|
|
|
key_stack_init();
|
|
key_stack_init();
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
|
|
+ } else
|
|
|
key_stack_push(DirectionNone);
|
|
key_stack_push(DirectionNone);
|
|
|
break;
|
|
break;
|
|
|
case InputKeyBack:
|
|
case InputKeyBack:
|
|
|
- if (game_state.scene == ScenePopup) {
|
|
|
|
|
|
|
+ if(game_state.scene == ScenePopup) {
|
|
|
game_state.scene = ScenePlay;
|
|
game_state.scene = ScenePlay;
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
|
|
+ } else {
|
|
|
storage_game_state_save();
|
|
storage_game_state_save();
|
|
|
sandbox_loop_exit();
|
|
sandbox_loop_exit();
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} else if(event.type == EventTypeTick) {
|
|
} else if(event.type == EventTypeTick) {
|
|
@@ -442,7 +439,6 @@ static void game_event_handler(GameEvent const event) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void game_alloc() {
|
|
static void game_alloc() {
|
|
|
- srand(DWT->CYCCNT);
|
|
|
|
|
key_stack_init();
|
|
key_stack_init();
|
|
|
notification = furi_record_open(RECORD_NOTIFICATION);
|
|
notification = furi_record_open(RECORD_NOTIFICATION);
|
|
|
notification_message_block(notification, &sequence_display_backlight_enforce_on);
|
|
notification_message_block(notification, &sequence_display_backlight_enforce_on);
|
|
@@ -459,16 +455,19 @@ int32_t game15_app() {
|
|
|
|
|
|
|
|
loaded_saving_ticks = 0;
|
|
loaded_saving_ticks = 0;
|
|
|
if(storage_game_state_load()) {
|
|
if(storage_game_state_load()) {
|
|
|
- if (game_state.scene != ScenePlay)
|
|
|
|
|
|
|
+ if(game_state.scene != ScenePlay)
|
|
|
game_init();
|
|
game_init();
|
|
|
else
|
|
else
|
|
|
loaded_saving_ticks = FPS;
|
|
loaded_saving_ticks = FPS;
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
|
|
+ } else
|
|
|
game_init();
|
|
game_init();
|
|
|
|
|
|
|
|
sandbox_init(
|
|
sandbox_init(
|
|
|
FPS, (SandboxRenderCallback)render_callback, (SandboxEventHandler)game_event_handler);
|
|
FPS, (SandboxRenderCallback)render_callback, (SandboxEventHandler)game_event_handler);
|
|
|
|
|
+
|
|
|
|
|
+ // Call dolphin deed on game start
|
|
|
|
|
+ dolphin_deed(DolphinDeedPluginGameStart);
|
|
|
|
|
+
|
|
|
sandbox_loop();
|
|
sandbox_loop();
|
|
|
sandbox_free();
|
|
sandbox_free();
|
|
|
game_free();
|
|
game_free();
|