#include #include #include "world.h" #include "game.h" void* init_game() { StavHry *stav = (StavHry*) malloc(sizeof(StavHry)); if (stav == NULL) return NULL; srand(time(NULL)); return stav; } void destroy_game(void* game) { free(game); } int world_event(struct event* event, void* game) { StavHry *stav = (StavHry*) game; if (event->type == EVENT_START) { inicializuj_hru(stav, event->width, event->height); } else if (event->type == EVENT_KEY) { if (event->key == 'q' || event->type == EVENT_ESC) return 1; spracuj_vstup(stav, event->key); } else if (event->type == EVENT_TIMEOUT) { aktualizuj_stav(stav); } vykresli_stav(stav); return 0; } int main() { return start_world(init_game, world_event, destroy_game); }