mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-22 05:14:46 -07:00
make arkanoid (not) great again
and small changes for other games
This commit is contained in:
@@ -61,6 +61,15 @@ typedef struct {
|
||||
InputEvent input;
|
||||
} SnakeEvent;
|
||||
|
||||
static const NotificationSequence sequence_short_vibro_and_sound = {
|
||||
&message_vibro_on,
|
||||
&message_note_c5,
|
||||
&message_delay_50,
|
||||
&message_sound_off,
|
||||
&message_vibro_off,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static void snake_game_render_callback(Canvas* const canvas, void* ctx) {
|
||||
const SnakeState* snake_state = acquire_mutex((ValueMutex*)ctx, 25);
|
||||
if(snake_state == NULL) {
|
||||
@@ -238,7 +247,7 @@ static void snake_game_move_snake(SnakeState* const snake_state, Point const nex
|
||||
snake_state->points[0] = next_step;
|
||||
}
|
||||
|
||||
static void snake_game_process_game_step(SnakeState* const snake_state) {
|
||||
static void snake_game_process_game_step(SnakeState* const snake_state, NotificationApp* notify) {
|
||||
if(snake_state->state == GameStateGameOver) {
|
||||
return;
|
||||
}
|
||||
@@ -273,10 +282,8 @@ static void snake_game_process_game_step(SnakeState* const snake_state) {
|
||||
|
||||
bool eatFruit = (next_step.x == snake_state->fruit.x) && (next_step.y == snake_state->fruit.y);
|
||||
if(eatFruit) {
|
||||
NotificationApp* notification = furi_record_open("notification");
|
||||
notification_message(notification, &sequence_single_vibro);
|
||||
notification_message(notification, &sequence_blink_white_100);
|
||||
furi_record_close("notification");
|
||||
notification_message(notify, &sequence_short_vibro_and_sound);
|
||||
notification_message(notify, &sequence_blink_white_100);
|
||||
|
||||
snake_state->len++;
|
||||
if(snake_state->len >= MAX_SNAKE_LEN) {
|
||||
@@ -320,6 +327,8 @@ int32_t snake_game_app(void* p) {
|
||||
Gui* gui = furi_record_open(RECORD_GUI);
|
||||
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
|
||||
|
||||
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
|
||||
|
||||
SnakeEvent event;
|
||||
for(bool processing = true; processing;) {
|
||||
FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100);
|
||||
@@ -354,7 +363,7 @@ int32_t snake_game_app(void* p) {
|
||||
}
|
||||
}
|
||||
} else if(event.type == EventTypeTick) {
|
||||
snake_game_process_game_step(snake_state);
|
||||
snake_game_process_game_step(snake_state, notification);
|
||||
}
|
||||
} else {
|
||||
// event timeout
|
||||
@@ -368,6 +377,7 @@ int32_t snake_game_app(void* p) {
|
||||
view_port_enabled_set(view_port, false);
|
||||
gui_remove_view_port(gui, view_port);
|
||||
furi_record_close(RECORD_GUI);
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
view_port_free(view_port);
|
||||
furi_message_queue_free(event_queue);
|
||||
delete_mutex(&state_mutex);
|
||||
|
||||
Reference in New Issue
Block a user