From 034340cfdad211d9af3e193526602094c5951a0b Mon Sep 17 00:00:00 2001 From: RogueMaster Date: Fri, 18 Nov 2022 00:14:20 -0500 Subject: [PATCH] trex update --- .../plugins/trex_runner/.editorconfig | 30 ++++++++++++++++ applications/plugins/trex_runner/.gitignore | 1 + applications/plugins/trex_runner/Makefile | 2 +- .../trex_runner/assets/HorizonLine0.png | Bin 0 -> 203 bytes .../trex_runner/assets/HorizonLine1.png | Bin 0 -> 272 bytes .../plugins/trex_runner/assets_icons.c | 33 ++++++++++++++++++ .../plugins/trex_runner/assets_icons.h | 2 ++ applications/plugins/trex_runner/trexrunner.c | 21 ++++++----- 8 files changed, 79 insertions(+), 10 deletions(-) create mode 100644 applications/plugins/trex_runner/.editorconfig create mode 100644 applications/plugins/trex_runner/assets/HorizonLine0.png create mode 100644 applications/plugins/trex_runner/assets/HorizonLine1.png diff --git a/applications/plugins/trex_runner/.editorconfig b/applications/plugins/trex_runner/.editorconfig new file mode 100644 index 000000000..8b9972089 --- /dev/null +++ b/applications/plugins/trex_runner/.editorconfig @@ -0,0 +1,30 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + +[*] + +# Change these settings to your own preference +indent_style = space +indent_size = 4 + +# We recommend you to keep these unchanged +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false + +[Makefile] +indent_style = tab + +[*.{yml,jade,js,css,lua,json}] +indent_size = 2 + +[*.go] +indent_style = tab +indent_size = 4 diff --git a/applications/plugins/trex_runner/.gitignore b/applications/plugins/trex_runner/.gitignore index 85e7c1dfc..7b6e9d57b 100644 --- a/applications/plugins/trex_runner/.gitignore +++ b/applications/plugins/trex_runner/.gitignore @@ -1 +1,2 @@ /.idea/ +/cmake-build-*/ diff --git a/applications/plugins/trex_runner/Makefile b/applications/plugins/trex_runner/Makefile index bea95dcb9..c9e3c6540 100644 --- a/applications/plugins/trex_runner/Makefile +++ b/applications/plugins/trex_runner/Makefile @@ -2,7 +2,7 @@ FLIPPER_FIRMWARE_PATH ?= /home/gelin/work/github/flipperzero-firmware/ .PHONY: build build: $(FLIPPER_FIRMWARE_PATH)/applications_user/t-rex-runner - cd $(FLIPPER_FIRMWARE_PATH) && ./fbt firmware_t-rex-runner + cd $(FLIPPER_FIRMWARE_PATH) && ./fbt fap_t-rex-runner .PHONY: launch launch: $(FLIPPER_FIRMWARE_PATH)/applications_user/t-rex-runner diff --git a/applications/plugins/trex_runner/assets/HorizonLine0.png b/applications/plugins/trex_runner/assets/HorizonLine0.png new file mode 100644 index 0000000000000000000000000000000000000000..b326cbb7f470f4d0796e18cbe8babfd065303422 GIT binary patch literal 203 zcmeAS@N?(olHy`uVBq!ia0y~yV2S{;c^H|2WQ#^%IFMos@Ck7R(%-*-&pmM_9>{9& zba4#PIG_B(-}Zok(3wSQ5_cYcJuj#D#b552Ro}85vfC{ce0l00Ec^5CKf4}l(qHCB z`wJ%iRCx67zkI;YDvrDSYUTgxeJ=F>Pw4rsap?Jfl9R zTq{#`%DM6hk$)2UKOR2v?s1ullm7p5m5=8OE;H=iqdDtX^Y(K`N<9fa_k_4qS!W_|n# zLio)(|A#oUp8u;q|F0g^EOa3MkAcDd0Rut6|DQn~T{kv6=b!&i4!~;G0eMQy`e%<6 z+i;VPqbY93lSF`;82-Rb`TZXe>>$=ZApVQ+H;B0Z{|8ha8tVOEa_9fYIQ490km z8rA=i#2=&kaX;84hmjoc5vJhpc?_>Yfju$@lx!LJ!5)KWocp*PiO|cBoZvshO#=Xk WcPDMu%7Baj0000dino_tick++; + uint32_t ticks_elapsed = furi_get_tick() - game_state->last_tick; + int delta_time_ms = ticks_elapsed * 1000 / furi_kernel_get_tick_frequency(); + + // dino update + game_state->dino_frame_ms += delta_time_ms; // TODO: switch by dino state - if(game_state->dino_tick >= DINO_RUNNING_TICKS) { + if(game_state->dino_frame_ms >= DINO_RUNNING_MS_PER_FRAME) { if(game_state->dino_icon == &I_DinoRun0) { game_state->dino_icon = &I_DinoRun1; } else { game_state->dino_icon = &I_DinoRun0; } - game_state->dino_tick = 0; + game_state->dino_frame_ms = 0; } release_mutex((ValueMutex*)ctx, game_state); @@ -71,7 +75,8 @@ static void render_callback(Canvas* const canvas, void* ctx) { } static void game_state_init(GameState* const game_state) { - game_state->dino_tick = 0; + game_state->last_tick = furi_get_tick(); + game_state->dino_frame_ms = 0; game_state->dino_icon = &I_Dino; } @@ -126,8 +131,6 @@ int32_t trexrunner_app(void* p) { // Exit the app processing = false; break; - default: - break; } } }