From 7feda832ede1ba8468eff2ca055fef3ddbdc16ac Mon Sep 17 00:00:00 2001 From: whoamins <40am1ns@github.com> Date: Wed, 23 Feb 2022 16:42:47 +0300 Subject: [PATCH] feat: Snake Game Score --- .gitignore | 3 +++ applications/snake_game/snake_game.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 319cf90c093d..f24c74e39085 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,9 @@ bindings/ .mxproject Brewfile.lock.json +# Visual Studio +.vs + # Visual Studio Code .vscode/ diff --git a/applications/snake_game/snake_game.c b/applications/snake_game/snake_game.c index 2bc0a6a332cc..a7bead00d2c0 100644 --- a/applications/snake_game/snake_game.c +++ b/applications/snake_game/snake_game.c @@ -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