Skip to content

Commit 7feda83

Browse files
author
whoamins
committed
feat: Snake Game Score
1 parent 3c77ae2 commit 7feda83

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ bindings/
2727
.mxproject
2828
Brewfile.lock.json
2929

30+
# Visual Studio
31+
.vs
32+
3033
# Visual Studio Code
3134
.vscode/
3235

applications/snake_game/snake_game.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ static void snake_game_render_callback(Canvas* const canvas, void* ctx) {
8282
canvas_draw_box(canvas, p.x, p.y, 4, 4);
8383
}
8484

85+
// Show score on the game field
86+
char buffer2[12];
87+
snprintf(buffer2, sizeof(buffer2), "Score: %u", snake_state->len - 7);
88+
canvas_draw_str_aligned(canvas, 64, 41, AlignCenter, AlignBottom, buffer2);
89+
8590
// Game Over banner
8691
if(snake_state->state == GameStateGameOver) {
8792
// Screen is 128x64 px

0 commit comments

Comments
 (0)