From 84e21cb5150968d227f43e103eab1952a16ce226 Mon Sep 17 00:00:00 2001 From: Nakidai Date: Mon, 30 Oct 2023 14:24:34 +0300 Subject: [PATCH] Add move to start of screen every tick --- src/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.c b/src/main.c index 18e5d70..cb52e00 100644 --- a/src/main.c +++ b/src/main.c @@ -26,6 +26,11 @@ Food generateFood(Player *player) return food; } +void resetCoordinates(void) +{ + printf("\033[0;0H"); +} + int main(int argc, char **argv) { srandom(time(NULL)); @@ -76,6 +81,7 @@ int main(int argc, char **argv) screenSet(screen, ' '); drawPlayer(player, screen); *screenGetPoint(screen, food.x, food.y) = '@'; + resetCoordinates(); screenShow(screen); for (i = 0; i < 20; ++i) putchar('-'); printf("\nScore: %d\n", player->score);