From 0d725f68e3d47e30896dc650791d28a875f6b0db Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 5 Sep 2023 14:33:49 +0300 Subject: [PATCH] Snake render grid lines without extra space after last '#' --- userspace/snake/main.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/userspace/snake/main.cpp b/userspace/snake/main.cpp index 82e1632413..bb532be013 100644 --- a/userspace/snake/main.cpp +++ b/userspace/snake/main.cpp @@ -81,8 +81,9 @@ void setup_grid() printf("\e[H\e[J"); // Render top line - for (int x = 0; x < g_grid_size.x + 2; x++) - printf("# "); + putchar('#'); + for (int x = 1; x < g_grid_size.x + 2; x++) + printf(" #"); putchar('\n'); // Render side lines @@ -90,8 +91,9 @@ void setup_grid() printf("#\e[%dC#\n", g_grid_size.x * 2 + 1); // Render Bottom line - for (int x = 0; x < g_grid_size.x + 2; x++) - printf("# "); + putchar('#'); + for (int x = 1; x < g_grid_size.x + 2; x++) + printf(" #"); putchar('\n'); // Render snake head