mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-14 10:48:35 -07:00
trex update
This commit is contained in:
30
applications/plugins/trex_runner/.editorconfig
Normal file
30
applications/plugins/trex_runner/.editorconfig
Normal file
@@ -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
|
||||||
1
applications/plugins/trex_runner/.gitignore
vendored
1
applications/plugins/trex_runner/.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
/.idea/
|
/.idea/
|
||||||
|
/cmake-build-*/
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ FLIPPER_FIRMWARE_PATH ?= /home/gelin/work/github/flipperzero-firmware/
|
|||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: $(FLIPPER_FIRMWARE_PATH)/applications_user/t-rex-runner
|
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
|
.PHONY: launch
|
||||||
launch: $(FLIPPER_FIRMWARE_PATH)/applications_user/t-rex-runner
|
launch: $(FLIPPER_FIRMWARE_PATH)/applications_user/t-rex-runner
|
||||||
|
|||||||
BIN
applications/plugins/trex_runner/assets/HorizonLine0.png
Normal file
BIN
applications/plugins/trex_runner/assets/HorizonLine0.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 203 B |
BIN
applications/plugins/trex_runner/assets/HorizonLine1.png
Normal file
BIN
applications/plugins/trex_runner/assets/HorizonLine1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 272 B |
@@ -27,9 +27,42 @@ const uint8_t _I_DinoRun1_0[] = {
|
|||||||
};
|
};
|
||||||
const uint8_t* const _I_DinoRun1[] = {_I_DinoRun1_0};
|
const uint8_t* const _I_DinoRun1[] = {_I_DinoRun1_0};
|
||||||
|
|
||||||
|
const uint8_t _I_HorizonLine0_0[] = {
|
||||||
|
0x01, 0x00, 0x9c, 0x00, 0x00, 0x78, 0x03, 0xc0, 0x1e, 0x00, 0xf0, 0x07, 0x80, 0x3c, 0x01, 0xe0,
|
||||||
|
0x0f, 0x00, 0x78, 0x03, 0xc0, 0x1e, 0x00, 0xf0, 0x07, 0x80, 0x3c, 0x01, 0xe0, 0x0f, 0x00, 0x78,
|
||||||
|
0x03, 0xc0, 0x17, 0xff, 0x00, 0x78, 0x03, 0xc0, 0x1e, 0x00, 0xf0, 0x04, 0x96, 0xbc, 0x01, 0xe0,
|
||||||
|
0x0f, 0x00, 0x78, 0x03, 0xc0, 0x1e, 0x00, 0xf0, 0x07, 0x80, 0x3c, 0x01, 0x78, 0x08, 0x18, 0x2e,
|
||||||
|
0xa0, 0xe0, 0x97, 0x8e, 0x09, 0x7a, 0x3c, 0x36, 0xf1, 0xa6, 0xf0, 0x08, 0x91, 0x20, 0x05, 0x88,
|
||||||
|
0x66, 0x01, 0x27, 0x80, 0x01, 0x95, 0x00, 0x23, 0x10, 0x60, 0x21, 0xc1, 0x20, 0x1e, 0x00, 0xfb,
|
||||||
|
0x40, 0x40, 0xeb, 0x0e, 0x02, 0xa5, 0x8a, 0x01, 0x38, 0x2d, 0x78, 0x03, 0xc9, 0x86, 0x00, 0x48,
|
||||||
|
0x40, 0x5b, 0x21, 0x80, 0x98, 0x0b, 0x91, 0x13, 0xe0, 0x48, 0x74, 0x9e, 0x1f, 0xaa, 0xe0, 0x1a,
|
||||||
|
0x7a, 0x00, 0xe0, 0x5c, 0xfe, 0x00, 0x66, 0x74, 0x00, 0x0e, 0x20, 0x03, 0x28, 0x7b, 0x55, 0x21,
|
||||||
|
0xe1, 0x27, 0x61, 0x08, 0x03, 0xd4, 0x50, 0x3a, 0x98, 0x78, 0xe0, 0xc0, 0x0f, 0x30, 0x26, 0x40,
|
||||||
|
};
|
||||||
|
const uint8_t* const _I_HorizonLine0[] = {_I_HorizonLine0_0};
|
||||||
|
|
||||||
|
const uint8_t _I_HorizonLine1_0[] = {
|
||||||
|
0x01, 0x00, 0xc6, 0x00, 0x00, 0x7f, 0x02, 0x1e, 0x11, 0xf0, 0x07, 0x80, 0x17, 0x01, 0x1f, 0x01,
|
||||||
|
0x18, 0x03, 0xc0, 0x19, 0x60, 0x8c, 0x04, 0x7c, 0x01, 0xe7, 0x26, 0x88, 0x00, 0x8c, 0x01, 0xe0,
|
||||||
|
0x0c, 0x9c, 0x4c, 0x02, 0x3e, 0x00, 0xf0, 0x02, 0xdc, 0x2c, 0x00, 0x23, 0x00, 0x78, 0x03, 0x21,
|
||||||
|
0x9c, 0x00, 0x8f, 0x80, 0x3c, 0x00, 0xb1, 0x8c, 0x04, 0x06, 0x18, 0x02, 0x10, 0x96, 0x7f, 0xc0,
|
||||||
|
0x1d, 0x07, 0xc0, 0x00, 0xc6, 0x07, 0xf8, 0x0a, 0xf8, 0x03, 0xc0, 0x03, 0x0f, 0x1c, 0x8c, 0x1c,
|
||||||
|
0x79, 0xc6, 0xdf, 0x00, 0x1c, 0x1a, 0x18, 0x11, 0xf0, 0x07, 0x80, 0x3c, 0x01, 0xe0, 0x08, 0xfe,
|
||||||
|
0x1b, 0xc4, 0x01, 0xe0, 0x0f, 0x00, 0x78, 0x02, 0x70, 0x10, 0x30, 0x5d, 0x12, 0x22, 0x38, 0x25,
|
||||||
|
0xe8, 0xf0, 0xdb, 0xc6, 0x9b, 0xc0, 0x22, 0x44, 0x80, 0x16, 0x21, 0x98, 0x04, 0x9e, 0x00, 0x06,
|
||||||
|
0x54, 0x07, 0xa4, 0x81, 0x0e, 0x09, 0x00, 0xf0, 0x07, 0xda, 0x02, 0x07, 0x58, 0x70, 0x15, 0x2c,
|
||||||
|
0x50, 0x09, 0xc1, 0x6b, 0xc0, 0x1e, 0x4c, 0x30, 0x02, 0x42, 0x02, 0xd9, 0x0c, 0x04, 0xc0, 0x5c,
|
||||||
|
0x88, 0x9f, 0x02, 0x43, 0xa4, 0xf0, 0xfd, 0x57, 0x00, 0xd3, 0xd0, 0x07, 0x02, 0xe7, 0xf0, 0x03,
|
||||||
|
0x33, 0xa0, 0x00, 0x71, 0x00, 0x19, 0x43, 0xda, 0xa9, 0x0f, 0x09, 0x3b, 0x08, 0x40, 0x1e, 0xa2,
|
||||||
|
0x81, 0xd4, 0xc3, 0xc7, 0x06, 0x00, 0x79, 0x81, 0x32, 0x00,
|
||||||
|
};
|
||||||
|
const uint8_t* const _I_HorizonLine1[] = {_I_HorizonLine1_0};
|
||||||
|
|
||||||
const Icon I_Dino =
|
const Icon I_Dino =
|
||||||
{.width = 20, .height = 22, .frame_count = 1, .frame_rate = 0, .frames = _I_Dino};
|
{.width = 20, .height = 22, .frame_count = 1, .frame_rate = 0, .frames = _I_Dino};
|
||||||
const Icon I_DinoRun0 =
|
const Icon I_DinoRun0 =
|
||||||
{.width = 20, .height = 22, .frame_count = 1, .frame_rate = 0, .frames = _I_DinoRun0};
|
{.width = 20, .height = 22, .frame_count = 1, .frame_rate = 0, .frames = _I_DinoRun0};
|
||||||
const Icon I_DinoRun1 =
|
const Icon I_DinoRun1 =
|
||||||
{.width = 20, .height = 22, .frame_count = 1, .frame_rate = 0, .frames = _I_DinoRun1};
|
{.width = 20, .height = 22, .frame_count = 1, .frame_rate = 0, .frames = _I_DinoRun1};
|
||||||
|
//const Icon I_HorizonLine0 = {.width=600,.height=12,.frame_count=1,.frame_rate=0,.frames=_I_HorizonLine0};
|
||||||
|
//const Icon I_HorizonLine1 = {.width=600,.height=12,.frame_count=1,.frame_rate=0,.frames=_I_HorizonLine1};
|
||||||
|
|||||||
@@ -5,3 +5,5 @@
|
|||||||
extern const Icon I_Dino;
|
extern const Icon I_Dino;
|
||||||
extern const Icon I_DinoRun0;
|
extern const Icon I_DinoRun0;
|
||||||
extern const Icon I_DinoRun1;
|
extern const Icon I_DinoRun1;
|
||||||
|
//extern const Icon I_HorizonLine0;
|
||||||
|
//extern const Icon I_HorizonLine1;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#define FPS 60
|
#define FPS 60
|
||||||
|
|
||||||
#define DINO_RUNNING_TICKS 15
|
#define DINO_RUNNING_MS_PER_FRAME 100
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EventTypeTick,
|
EventTypeTick,
|
||||||
@@ -26,8 +26,9 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
FuriTimer* timer;
|
FuriTimer* timer;
|
||||||
|
uint32_t last_tick;
|
||||||
const Icon* dino_icon;
|
const Icon* dino_icon;
|
||||||
int dino_tick;
|
int dino_frame_ms;
|
||||||
} GameState;
|
} GameState;
|
||||||
|
|
||||||
static void timer_callback(void* ctx) {
|
static void timer_callback(void* ctx) {
|
||||||
@@ -36,16 +37,19 @@ static void timer_callback(void* ctx) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// game update
|
uint32_t ticks_elapsed = furi_get_tick() - game_state->last_tick;
|
||||||
game_state->dino_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
|
// 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) {
|
if(game_state->dino_icon == &I_DinoRun0) {
|
||||||
game_state->dino_icon = &I_DinoRun1;
|
game_state->dino_icon = &I_DinoRun1;
|
||||||
} else {
|
} else {
|
||||||
game_state->dino_icon = &I_DinoRun0;
|
game_state->dino_icon = &I_DinoRun0;
|
||||||
}
|
}
|
||||||
game_state->dino_tick = 0;
|
game_state->dino_frame_ms = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
release_mutex((ValueMutex*)ctx, game_state);
|
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) {
|
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;
|
game_state->dino_icon = &I_Dino;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,8 +131,6 @@ int32_t trexrunner_app(void* p) {
|
|||||||
// Exit the app
|
// Exit the app
|
||||||
processing = false;
|
processing = false;
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user