pvjc25/a3/world.c
2025-04-23 14:42:36 +00:00

22 lines
508 B
C

#include <stdio.h>
#include <stdlib.h>
#include "snake.h"
void render(const struct state* state) {
system("clear");
// Малюємо поле
for (int y = 0; y < state->height; y++) {
for (int x = 0; x < state->width; x++) {
if (is_snake(state->snake, x, y)) {
printf("O");
} else if (is_food_at(state, x, y)) {
printf("@");
} else {
printf(" ");
}
}
printf("\n");
}
}