Skip to content

Commit 69d2ef1

Browse files
committed
vibrate on hitting mine, fix empty cell graphic
1 parent 1171f95 commit 69d2ef1

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

application.fam

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ App(
55
entry_point="minesweeper_app",
66
cdefines=["APP_MINESWEEPER"],
77
requires=["gui"],
8-
stack_size=2 * 1024,
8+
stack_size=8 * 1024,
99
fap_category="Games",
1010
order=35,
1111
)

assets.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#define tile_0_width 8
22
#define tile_0_height 8
33
static uint8_t tile_0_bits[] = {
4-
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, };
4+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
55
#define tile_1_width 8
66
#define tile_1_height 8
77
static uint8_t tile_1_bits[] = {

minesweeper.c

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <input/input.h>
55
#include <stdlib.h>
66

7+
#include <notification/notification_messages.h>
8+
79
#include "assets.h"
810

911
#define PLAYFIELD_WIDTH 16
@@ -209,6 +211,13 @@ static void place_flag(Minesweeper* minesweeper_state) {
209211
}
210212
}
211213

214+
static void game_lost() {
215+
NotificationApp* notifications = furi_record_open(RECORD_NOTIFICATION);
216+
notification_message(notifications, &sequence_set_vibro_on);
217+
furi_delay_ms(200);
218+
notification_message(notifications, &sequence_reset_vibro);
219+
furi_record_close(RECORD_NOTIFICATION);
220+
}
212221

213222
static void play_move(Minesweeper* minesweeper_state, int cursor_x, int cursor_y) {
214223
if (minesweeper_state->playfield[cursor_x][cursor_y] != TileTypeUncleared) {
@@ -217,6 +226,8 @@ static void play_move(Minesweeper* minesweeper_state, int cursor_x, int cursor_y
217226
}
218227
if (minesweeper_state->minefield[cursor_x][cursor_y] == FieldMine) {
219228
// TODO: player loses!
229+
minesweeper_state->playfield[cursor_x][cursor_y] = TileTypeMine;
230+
game_lost();
220231
return;
221232
} else {
222233
// get number of surrounding mines.

0 commit comments

Comments
 (0)