diff --git a/src/core.h b/src/core.h index f6f5047..3c537d7 100644 --- a/src/core.h +++ b/src/core.h @@ -1,6 +1,8 @@ #ifndef _PLAGUE_CORE_H #define _PLAGUE_CORE_H +#include + // Duration for internal clock (ms) #define ENGINE_TICK 50 #define CURSOR_TICK 150 @@ -12,6 +14,12 @@ // Number of planes on screen #define NB_PLANES 5 +struct grid { + int width; + int height; + uint8_t *data; +}; + // game : all statistics of the current game struct game { @@ -36,7 +44,7 @@ struct game struct plane *planes[NB_PLANES + 1]; // Grid for epidemologic model - int grid[16][32]; + struct grid grid; }; // plane : information about planes @@ -81,4 +89,4 @@ int callback_tick(volatile int *tick); // message : display a message void message(const char *msg[5]); -#endif /* _PLAGUE_CORE_H */ \ No newline at end of file +#endif /* _PLAGUE_CORE_H */ diff --git a/src/main.c b/src/main.c index dd6ab59..3ca085a 100644 --- a/src/main.c +++ b/src/main.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include "core.h" #include "display_engine.h" @@ -59,11 +61,18 @@ int main(void) .planes = {&plane_1, &plane_2, &plane_3, &plane_4, &plane_5, NULL}, - .grid = {{0}}, + .grid = { 128, 64, NULL }, }; + /* allocate memory */ + current_game.grid.data = calloc(current_game.grid.width * + current_game.grid.height, sizeof(uint8_t)); + main_loop(¤t_game); + /* free memory */ + free(current_game.grid.data); + return 1; }