diff --git a/a3/main.c b/a3/main.c index 6d38162..63e4da7 100644 --- a/a3/main.c +++ b/a3/main.c @@ -11,14 +11,14 @@ int main() { for (int x = 0; xwidth; 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;