From 3387b1606c04ed713b81500e62d5a631d703f4d4 Mon Sep 17 00:00:00 2001 From: Anzhelika Nikolaieva Date: Sun, 23 Apr 2023 12:24:57 +0000 Subject: [PATCH] Update 'a3/game.c' --- a3/game.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/a3/game.c b/a3/game.c index e795070..549072b 100644 --- a/a3/game.c +++ b/a3/game.c @@ -33,6 +33,19 @@ int game_event(struct event* event,void* game){ } // Read game variable and update the eventstate + + +void update_game(struct game_state *game, char input){ +// update cat position based on input + switch (input) { + 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(); @@ -99,7 +112,18 @@ int game_event(struct event* event,void* game){ set_color_cell('-',state->catx_position-1,state->caty_position,COLOR_YELLOW,COLOR_GREEN); //set_cell('c',state->catx_position,state->caty_position); // Draw mouse - set_cell('m',state->mousex,state->mousey); + + for (i = 0; i < MOUSE_COUNT; i++) { + if (state->mousex[i] == -1) continue; + set_cell('m',state->mousex,state->mousey); + } + + + for (i = 0; i < COLS; i++) set_color_cell('-', i, 0, 0, (rand() % 7) + 1); + for (i = 0; i < LINES; i++) set_color_cell('-', 0, i, 0, (rand() % 7) + 1); + for (i = 0; i < COLS; i++) set_color_cell('-', i, LINES - 1, 0, (rand() % 7) + 1); + for (i = 0; i < LINES; i++) set_color_cell('-', COLS - 1, i, 0, (rand() % 7) + 1); + set_message( state->message,1,0); return 0; }