This commit is contained in:
RogueMaster
2022-10-29 03:27:33 -04:00
parent 952810f16a
commit c7d18b3fcc
3 changed files with 117 additions and 95 deletions

View File

@@ -2,16 +2,34 @@
#include <gui/icon_i.h>
const uint8_t _I_Dino_0[] = {0x01,0x00,0x3d,0x00,0x80,0x7e,0x20,0xf0,0x0f,0xe4,0x3e,0x01,0xec,0x01,0x08,0x14,0x80,0x4b,0x7c,0x0a,0x0f,0xf2,0x07,0x01,0x9f,0x40,0x30,0x33,0xf8,0x07,0x0f,0xff,0x00,0xf3,0xef,0xe0,0x1f,0xf0,0x40,0x80,0x8b,0xfd,0x1f,0x0b,0x08,0x08,0x7f,0x01,0xf1,0xf8,0x0c,0x47,0xc1,0x06,0x80,0x58,0x20,0x90,0x09,0x00,0x08,0x6c,0x10,0xc8,0x00,};
const uint8_t _I_Dino_0[] = {
0x01, 0x00, 0x3d, 0x00, 0x80, 0x7e, 0x20, 0xf0, 0x0f, 0xe4, 0x3e, 0x01, 0xec,
0x01, 0x08, 0x14, 0x80, 0x4b, 0x7c, 0x0a, 0x0f, 0xf2, 0x07, 0x01, 0x9f, 0x40,
0x30, 0x33, 0xf8, 0x07, 0x0f, 0xff, 0x00, 0xf3, 0xef, 0xe0, 0x1f, 0xf0, 0x40,
0x80, 0x8b, 0xfd, 0x1f, 0x0b, 0x08, 0x08, 0x7f, 0x01, 0xf1, 0xf8, 0x0c, 0x47,
0xc1, 0x06, 0x80, 0x58, 0x20, 0x90, 0x09, 0x00, 0x08, 0x6c, 0x10, 0xc8, 0x00,
};
const uint8_t* const _I_Dino[] = {_I_Dino_0};
const uint8_t _I_DinoRun0_0[] = {0x01,0x00,0x3b,0x00,0x80,0x7e,0x20,0xf0,0x0f,0xe4,0x3e,0x01,0xec,0x01,0x08,0x14,0x80,0x4b,0x7c,0x0a,0x0f,0xf2,0x07,0x01,0x9f,0x40,0x30,0x33,0xf8,0x07,0x0f,0xff,0x00,0xf3,0xef,0xe0,0x1f,0xf0,0x40,0x80,0x8b,0xfd,0x1f,0x0b,0x08,0x08,0x7f,0x01,0xf1,0xf8,0x0c,0x47,0xc1,0x0c,0x80,0x58,0x04,0xa3,0x20,0x01,0x08,0x14,0x80,};
const uint8_t _I_DinoRun0_0[] = {
0x01, 0x00, 0x3b, 0x00, 0x80, 0x7e, 0x20, 0xf0, 0x0f, 0xe4, 0x3e, 0x01, 0xec, 0x01, 0x08, 0x14,
0x80, 0x4b, 0x7c, 0x0a, 0x0f, 0xf2, 0x07, 0x01, 0x9f, 0x40, 0x30, 0x33, 0xf8, 0x07, 0x0f, 0xff,
0x00, 0xf3, 0xef, 0xe0, 0x1f, 0xf0, 0x40, 0x80, 0x8b, 0xfd, 0x1f, 0x0b, 0x08, 0x08, 0x7f, 0x01,
0xf1, 0xf8, 0x0c, 0x47, 0xc1, 0x0c, 0x80, 0x58, 0x04, 0xa3, 0x20, 0x01, 0x08, 0x14, 0x80,
};
const uint8_t* const _I_DinoRun0[] = {_I_DinoRun0_0};
const uint8_t _I_DinoRun1_0[] = {0x01,0x00,0x3b,0x00,0x80,0x7e,0x20,0xf0,0x0f,0xe4,0x3e,0x01,0xec,0x01,0x08,0x14,0x80,0x4b,0x7c,0x0a,0x0f,0xf2,0x07,0x01,0x9f,0x40,0x30,0x33,0xf8,0x07,0x0f,0xff,0x00,0xf3,0xef,0xe0,0x1f,0xf0,0x40,0x80,0x8b,0xfd,0x1f,0x0b,0x08,0x08,0x7f,0x01,0xf1,0xf8,0x0c,0x46,0xc1,0x06,0x80,0x70,0x20,0x82,0x61,0x01,0x14,0x32,0x00,};
const uint8_t _I_DinoRun1_0[] = {
0x01, 0x00, 0x3b, 0x00, 0x80, 0x7e, 0x20, 0xf0, 0x0f, 0xe4, 0x3e, 0x01, 0xec, 0x01, 0x08, 0x14,
0x80, 0x4b, 0x7c, 0x0a, 0x0f, 0xf2, 0x07, 0x01, 0x9f, 0x40, 0x30, 0x33, 0xf8, 0x07, 0x0f, 0xff,
0x00, 0xf3, 0xef, 0xe0, 0x1f, 0xf0, 0x40, 0x80, 0x8b, 0xfd, 0x1f, 0x0b, 0x08, 0x08, 0x7f, 0x01,
0xf1, 0xf8, 0x0c, 0x46, 0xc1, 0x06, 0x80, 0x70, 0x20, 0x82, 0x61, 0x01, 0x14, 0x32, 0x00,
};
const uint8_t* const _I_DinoRun1[] = {_I_DinoRun1_0};
const Icon I_Dino = {.width=20,.height=22,.frame_count=1,.frame_rate=0,.frames=_I_Dino};
const Icon I_DinoRun0 = {.width=20,.height=22,.frame_count=1,.frame_rate=0,.frames=_I_DinoRun0};
const Icon I_DinoRun1 = {.width=20,.height=22,.frame_count=1,.frame_rate=0,.frames=_I_DinoRun1};
const Icon I_Dino =
{.width = 20, .height = 22, .frame_count = 1, .frame_rate = 0, .frames = _I_Dino};
const Icon I_DinoRun0 =
{.width = 20, .height = 22, .frame_count = 1, .frame_rate = 0, .frames = _I_DinoRun0};
const Icon I_DinoRun1 =
{.width = 20, .height = 22, .frame_count = 1, .frame_rate = 0, .frames = _I_DinoRun1};

View File

@@ -32,15 +32,15 @@ typedef struct {
static void timer_callback(void* ctx) {
GameState* game_state = acquire_mutex((ValueMutex*)ctx, 25);
if (game_state == NULL) {
if(game_state == NULL) {
return;
}
// game update
game_state->dino_tick++;
// TODO: switch by dino state
if (game_state->dino_tick >= DINO_RUNNING_TICKS) {
if (game_state->dino_icon == &I_DinoRun0) {
if(game_state->dino_tick >= DINO_RUNNING_TICKS) {
if(game_state->dino_icon == &I_DinoRun0) {
game_state->dino_icon = &I_DinoRun1;
} else {
game_state->dino_icon = &I_DinoRun0;
@@ -60,11 +60,11 @@ static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queu
static void render_callback(Canvas* const canvas, void* ctx) {
const GameState* game_state = acquire_mutex((ValueMutex*)ctx, 25);
if (game_state == NULL) {
if(game_state == NULL) {
return;
}
// canvas_draw_xbm(canvas, 0, 0, dino_width, dino_height, dino_bits);
// canvas_draw_xbm(canvas, 0, 0, dino_width, dino_height, dino_bits);
canvas_draw_icon(canvas, DINO_START_X, DINO_START_Y, game_state->dino_icon);
release_mutex((ValueMutex*)ctx, game_state);
@@ -84,7 +84,7 @@ int32_t trexrunner_app(void* p) {
game_state_init(game_state);
ValueMutex state_mutex;
if (!init_mutex(&state_mutex, game_state, sizeof(game_state))) {
if(!init_mutex(&state_mutex, game_state, sizeof(game_state))) {
FURI_LOG_E("T-rex runner", "cannot create mutex\r\n");
free(game_state);
return 255;
@@ -97,26 +97,31 @@ int32_t trexrunner_app(void* p) {
view_port_input_callback_set(view_port, input_callback, event_queue);
game_state->timer = furi_timer_alloc(timer_callback, FuriTimerTypePeriodic, &state_mutex);
furi_timer_start(game_state->timer, (uint32_t) furi_kernel_get_tick_frequency() / FPS);
furi_timer_start(game_state->timer, (uint32_t)furi_kernel_get_tick_frequency() / FPS);
// Open GUI and register view_port
Gui* gui = furi_record_open("gui");
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
PluginEvent event;
for (bool processing = true; processing;) {
for(bool processing = true; processing;) {
FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100);
// Minesweeper* minesweeper_state = (Minesweeper*)acquire_mutex_block(&state_mutex);
if (event_status == FuriStatusOk) {
// Minesweeper* minesweeper_state = (Minesweeper*)acquire_mutex_block(&state_mutex);
if(event_status == FuriStatusOk) {
// press events
if (event.type == EventTypeKey) {
if (event.input.type == InputTypeShort) {
switch (event.input.key) {
case InputKeyUp: break;
case InputKeyDown: break;
case InputKeyLeft: break;
case InputKeyRight: break;
case InputKeyOk: break;
if(event.type == EventTypeKey) {
if(event.input.type == InputTypeShort) {
switch(event.input.key) {
case InputKeyUp:
break;
case InputKeyDown:
break;
case InputKeyLeft:
break;
case InputKeyRight:
break;
case InputKeyOk:
break;
case InputKeyBack:
// Exit the app
processing = false;

View File

@@ -8,7 +8,6 @@
#include <notification/notification.h>
#include <notification/notification_messages.h>
#include <flipper_format/flipper_format_i.h>
#include <lib/toolbox/path.h>
#include <applications/main/subghz/subghz_i.h>