Skip to content

Commit

Permalink
feat: Snake Game Score
Browse files Browse the repository at this point in the history
  • Loading branch information
whoamins committed Feb 23, 2022
1 parent 3c77ae2 commit 7feda83
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ bindings/
.mxproject
Brewfile.lock.json

# Visual Studio
.vs

# Visual Studio Code
.vscode/

Expand Down
5 changes: 5 additions & 0 deletions applications/snake_game/snake_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ static void snake_game_render_callback(Canvas* const canvas, void* ctx) {
canvas_draw_box(canvas, p.x, p.y, 4, 4);
}

// Show score on the game field
char buffer2[12];
snprintf(buffer2, sizeof(buffer2), "Score: %u", snake_state->len - 7);
canvas_draw_str_aligned(canvas, 64, 41, AlignCenter, AlignBottom, buffer2);

// Game Over banner
if(snake_state->state == GameStateGameOver) {
// Screen is 128x64 px
Expand Down

0 comments on commit 7feda83

Please sign in to comment.