Skip to content

Commit

Permalink
vibrate on hitting mine, fix empty cell graphic
Browse files Browse the repository at this point in the history
  • Loading branch information
panki27 committed Sep 23, 2022
1 parent 1171f95 commit 69d2ef1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ App(
entry_point="minesweeper_app",
cdefines=["APP_MINESWEEPER"],
requires=["gui"],
stack_size=2 * 1024,
stack_size=8 * 1024,
fap_category="Games",
order=35,
)
2 changes: 1 addition & 1 deletion assets.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define tile_0_width 8
#define tile_0_height 8
static uint8_t tile_0_bits[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, };
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
#define tile_1_width 8
#define tile_1_height 8
static uint8_t tile_1_bits[] = {
Expand Down
11 changes: 11 additions & 0 deletions minesweeper.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <input/input.h>
#include <stdlib.h>

#include <notification/notification_messages.h>

#include "assets.h"

#define PLAYFIELD_WIDTH 16
Expand Down Expand Up @@ -209,6 +211,13 @@ static void place_flag(Minesweeper* minesweeper_state) {
}
}

static void game_lost() {
NotificationApp* notifications = furi_record_open(RECORD_NOTIFICATION);
notification_message(notifications, &sequence_set_vibro_on);
furi_delay_ms(200);
notification_message(notifications, &sequence_reset_vibro);
furi_record_close(RECORD_NOTIFICATION);
}

static void play_move(Minesweeper* minesweeper_state, int cursor_x, int cursor_y) {
if (minesweeper_state->playfield[cursor_x][cursor_y] != TileTypeUncleared) {
Expand All @@ -217,6 +226,8 @@ static void play_move(Minesweeper* minesweeper_state, int cursor_x, int cursor_y
}
if (minesweeper_state->minefield[cursor_x][cursor_y] == FieldMine) {
// TODO: player loses!
minesweeper_state->playfield[cursor_x][cursor_y] = TileTypeMine;
game_lost();
return;
} else {
// get number of surrounding mines.
Expand Down

0 comments on commit 69d2ef1

Please sign in to comment.