snake: Remove random goto statements when regenerating apple's position

This commit is contained in:
Bananymous 2024-08-16 17:36:37 +03:00
parent b1fe24bb57
commit 46b34817d2
1 changed files with 10 additions and 7 deletions

View File

@ -65,13 +65,16 @@ Point get_random_point()
void update_apple()
{
regenerate:
for (;;)
{
g_apple = get_random_point();
if (g_head == g_apple)
goto regenerate;
continue;
for (auto point : g_tail)
if (point == g_apple)
goto regenerate;
continue;
break;
}
set_grid_tile(g_apple, "\e[31mO");
}