diff --git a/a3/game.c b/a3/game.c index 13faa69..f3a0d34 100644 --- a/a3/game.c +++ b/a3/game.c @@ -4,7 +4,7 @@ #include "world.h" #include "game.h" - void* init_game(){ + void* init_game(struct game *game){ // Allocate memory for the state struct game* st = calloc(1,(sizeof(struct game))); // Initialize state @@ -32,6 +32,23 @@ int game_event(struct event* event,void* game){ } // Read game variable and update the eventstate + void update_game(struct game *game, int key){ +// Move the cat based on the pressed key + switch(key) { + case 'w': + game->caty -= 1; + break; + case 's': + game->caty += 1; + break; + case 'a': + game->catx -= 1; + break; + case 'd': + game->catx += 1; + break; + } + // Is mouse caught ? if ((state->caty_position == state->mousey) && (state->catx_position == state->mousex)){ clear_screen();