This commit is contained in:
Felix Pankratz 2022-09-23 21:55:58 +02:00
parent ed92ecdb27
commit 4e7970f53f
14 changed files with 107 additions and 2 deletions

48
assets/asset Normal file
View File

@ -0,0 +1,48 @@
#define tile_0_width 8
#define tile_0_height 8
static uint8_t tile_0_bits[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, };
#define tile_1_width 8
#define tile_1_height 8
static uint8_t tile_1_bits[] = {
0x00, 0x10, 0x18, 0x10, 0x10, 0x10, 0x10, 0x00, };
#define tile_2_width 8
#define tile_2_height 8
static uint8_t tile_2_bits[] = {
0x00, 0x1C, 0x20, 0x20, 0x18, 0x04, 0x3C, 0x00, };
#define tile_3_width 8
#define tile_3_height 8
static uint8_t tile_3_bits[] = {
0x00, 0x1C, 0x20, 0x20, 0x18, 0x20, 0x1C, 0x00, };
#define tile_4_width 8
#define tile_4_height 8
static uint8_t tile_4_bits[] = {
0x00, 0x04, 0x14, 0x14, 0x3C, 0x10, 0x10, 0x00, };
#define tile_5_width 8
#define tile_5_height 8
static uint8_t tile_5_bits[] = {
0x00, 0x3C, 0x04, 0x1C, 0x20, 0x20, 0x1C, 0x00, };
#define tile_6_width 8
#define tile_6_height 8
static uint8_t tile_6_bits[] = {
0x00, 0x18, 0x24, 0x04, 0x1C, 0x24, 0x18, 0x00, };
#define tile_7_width 8
#define tile_7_height 8
static uint8_t tile_7_bits[] = {
0x00, 0x3C, 0x20, 0x20, 0x10, 0x08, 0x08, 0x00, };
#define tile_8_width 8
#define tile_8_height 8
static uint8_t tile_8_bits[] = {
0x00, 0x18, 0x24, 0x18, 0x24, 0x24, 0x18, 0x00, };
#define tile_flag_width 8
#define tile_flag_height 8
static uint8_t tile_flag_bits[] = {
0xFF, 0x81, 0xB9, 0x89, 0x89, 0x9D, 0x81, 0xFF, };
#define tile_mine_width 8
#define tile_mine_height 8
static uint8_t tile_mine_bits[] = {
0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, };
#define tile_uncleared_width 8
#define tile_uncleared_height 8
static uint8_t tile_uncleared_bits[] = {
0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, };

4
assets/tile_0.xbm Normal file
View File

@ -0,0 +1,4 @@
#define tile_0_width 8
#define tile_0_height 8
static char tile_0_bits[] = {
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, };

4
assets/tile_1.xbm Normal file
View File

@ -0,0 +1,4 @@
#define tile_1_width 8
#define tile_1_height 8
static uint8_t tile_1_bits[] = {
0x00, 0x10, 0x18, 0x10, 0x10, 0x10, 0x10, 0x00, };

4
assets/tile_2.xbm Normal file
View File

@ -0,0 +1,4 @@
#define tile_2_width 8
#define tile_2_height 8
static uint8_t tile_2_bits[] = {
0x00, 0x1C, 0x20, 0x20, 0x18, 0x04, 0x3C, 0x00, };

4
assets/tile_3.xbm Normal file
View File

@ -0,0 +1,4 @@
#define tile_3_width 8
#define tile_3_height 8
static uint8_t tile_3_bits[] = {
0x00, 0x1C, 0x20, 0x20, 0x18, 0x20, 0x1C, 0x00, };

4
assets/tile_4.xbm Normal file
View File

@ -0,0 +1,4 @@
#define tile_4_width 8
#define tile_4_height 8
static uint8_t tile_4_bits[] = {
0x00, 0x04, 0x14, 0x14, 0x3C, 0x10, 0x10, 0x00, };

4
assets/tile_5.xbm Normal file
View File

@ -0,0 +1,4 @@
#define tile_5_width 8
#define tile_5_height 8
static uint8_t tile_5_bits[] = {
0x00, 0x3C, 0x04, 0x1C, 0x20, 0x20, 0x1C, 0x00, };

4
assets/tile_6.xbm Normal file
View File

@ -0,0 +1,4 @@
#define tile_6_width 8
#define tile_6_height 8
static uint8_t tile_6_bits[] = {
0x00, 0x18, 0x24, 0x04, 0x1C, 0x24, 0x18, 0x00, };

4
assets/tile_7.xbm Normal file
View File

@ -0,0 +1,4 @@
#define tile_7_width 8
#define tile_7_height 8
static uint8_t tile_7_bits[] = {
0x00, 0x3C, 0x20, 0x20, 0x10, 0x08, 0x08, 0x00, };

4
assets/tile_8.xbm Normal file
View File

@ -0,0 +1,4 @@
#define tile_8_width 8
#define tile_8_height 8
static uint8_t tile_8_bits[] = {
0x00, 0x18, 0x24, 0x18, 0x24, 0x24, 0x18, 0x00, };

4
assets/tile_flag.xbm Normal file
View File

@ -0,0 +1,4 @@
#define tile_flag_width 8
#define tile_flag_height 8
static uint8_t tile_flag_bits[] = {
0xFF, 0x81, 0xB9, 0x89, 0x89, 0x9D, 0x81, 0xFF, };

4
assets/tile_mine.xbm Normal file
View File

@ -0,0 +1,4 @@
#define tile_mine_width 8
#define tile_mine_height 8
static uint8_t tile_mine_bits[] = {
0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, };

View File

@ -1,4 +1,4 @@
#define tile_uncleared_width 8
#define tile_uncleared_height 8
static char tile_uncleared_bits[] = {
static uint8_t tile_uncleared_bits[] = {
0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, };

View File

@ -57,6 +57,7 @@ typedef struct {
int flags_set;
bool game_started;
bool showing_dialog;
uint32_t game_started_tick;
} Minesweeper;
static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) {
@ -81,7 +82,18 @@ static void render_callback(Canvas* const canvas, void* ctx) {
canvas_set_font(canvas, FontSecondary);
canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, string_get_cstr(tempStr));
string_clear(tempStr);
int seconds = 0;
int minutes = 0;
if (minesweeper_state->game_started) {
uint32_t ticks_elapsed = furi_get_tick() - minesweeper_state->game_started_tick;
seconds = (int) ticks_elapsed / furi_kernel_get_tick_frequency();
minutes = (int) seconds / 60;
seconds = seconds % 60;
}
string_printf(tempStr, "%01d:%02d", minutes, seconds);
canvas_draw_str_aligned(canvas, 128, 0, AlignRight, AlignTop, string_get_cstr(tempStr));
string_clear(tempStr);
for (int y = 0; y < PLAYFIELD_HEIGHT; y++) {
for (int x = 0; x < PLAYFIELD_WIDTH; x++) {
if ( x == minesweeper_state->cursor_x && y == minesweeper_state->cursor_y) {
@ -226,6 +238,7 @@ static void setup_playfield(Minesweeper* minesweeper_state) {
minesweeper_state->mines_left = MINECOUNT;
minesweeper_state->fields_cleared = 0;
minesweeper_state->flags_set = 0;
minesweeper_state->game_started_tick = furi_get_tick();
}
}