Initialization

This commit is contained in:
Kozar 2024-04-26 14:13:39 +02:00
parent 04c0ba0717
commit 995af98378

View File

@ -2,21 +2,20 @@
#include <curses.h> #include <curses.h>
#include <string.h> #include <string.h>
#include "world.h" #include "world.h"
#include "snake.h"
// Game state structure
struct state {
int width;
int height;
int sx;
int sy;
struct snake* snake;
int foodx[5];
int foody[5];
};
// Initialize game state // Initialize game state
void* init_game() { void* init_game() {
struct state* st = calloc(1, sizeof(struct state)); struct state* st = calloc(1, sizeof(struct state));
st->width = 0;
st->height = 0;
st->sx = 0;
st->sy = 0;
st->snake = NULL;
for (int i = 0; i < 5; i++) {
st->foodx[i] = 0;
st->foody[i] = 0;
}
return st; return st;
} }