diff --git a/bomber.c b/bomber.c index 278ce34b43b..efd5a456750 100644 --- a/bomber.c +++ b/bomber.c @@ -104,7 +104,13 @@ bool bomber_app_init() void bomber_game_update_timer_callback() { - bomber_game_tick(state); + FURI_LOG_T(TAG, "Timer Callback"); + + BomberEvent event = {.type = BomberEventType_Tick }; + + if(furi_message_queue_put(state->queue, &event, FuriWaitForever) != FuriStatusOk) { + FURI_LOG_W(TAG, "Failed to put timer event in message queue"); + } } void bomber_app_destroy() diff --git a/bomber_loop.c b/bomber_loop.c index a772804c806..f30a3120dfa 100644 --- a/bomber_loop.c +++ b/bomber_loop.c @@ -204,6 +204,9 @@ void bomber_main_loop(BomberAppState* state) { case BomberEventType_Input: updated = bomber_app_handle_input(state, event.input); break; + case BomberEventType_Tick: + updated = bomber_game_tick(state); + break; default: FURI_LOG_E(TAG, "Unknown event received from queue."); break; @@ -295,12 +298,10 @@ static bool update_bombs(Player* player, BomberAppState* state) { return changed; } -void bomber_game_tick(BomberAppState* state) { +bool bomber_game_tick(BomberAppState* state) { bool changed = false; changed &= update_bombs(&state->fox, state); changed &= update_bombs(&state->wolf, state); - if(changed) { - view_port_update(state->view_port); - } + return changed; } diff --git a/bomber_loop.h b/bomber_loop.h index 1e76e0d37c2..3e83292598c 100644 --- a/bomber_loop.h +++ b/bomber_loop.h @@ -4,6 +4,6 @@ #include "types.h" void bomber_main_loop(BomberAppState* state); -void bomber_game_tick(BomberAppState* state); +bool bomber_game_tick(BomberAppState* state); #endif \ No newline at end of file diff --git a/types.h b/types.h index fc03b79e69c..df358431916 100644 --- a/types.h +++ b/types.h @@ -96,7 +96,6 @@ typedef enum { // Event types for message queue typedef enum { BomberEventType_Input, - BomberEventType_InfraredMessage, BomberEventType_Tick, } BomberEventType;