Aktualizovat a3/main.c

This commit is contained in:
Mykola Syniavskyi 2025-05-02 10:16:29 +00:00
parent 743129a302
commit df5ead6041

View File

@ -11,14 +11,14 @@ int main() {
for (int x = 0; x<st->width; x++) {
if (is_snake(st->snake, x, y)) {
printf("O");
} else {
int food = 0;
for (int i = 0; i < FOOD_COUNT; i++) {
if (st->foodx[i] == x && st->foody[i] == y) {
food = 1;
break;
}
}
} else {
int food = 0;
for (int i = 0; i < FOOD_COUNT; i++) {
if (st->foodx[i] == x && st->foody[i] == y) {
food = 1;
break;
}
}
printf(food ? "*" : ".");
}
}
@ -30,17 +30,17 @@ int main() {
scanf(" %c", &c);
if (c == 'w') change_direction(st, 0, -1);
else if (c == 's') change_direction(st, 0, 1);
else if (c == 'a') change_direction(st, -1, 0);
else if (c == 'd') change_direction(st, 1, 0);
else if (c == 'q') break;
else if (c == 's') change_direction(st, 0, 1);
else if (c == 'a') change_direction(st, -1, 0);
else if (c == 'd') change_direction(st, 1, 0);
else if (c == 'q') break;
int res = step_state(st);
if (res != END_CONTINUE) {
printf("End of game: %d\n", res);
break;
}
}
if (res != END_CONTINUE) {
printf("End of game: %d\n", res);
break;
}
}
free_world(st);
return 0;