Update 'a3/game.c'
This commit is contained in:
parent
4fb79ccaa3
commit
b0887fa624
25
a3/game.c
25
a3/game.c
@ -108,14 +108,35 @@ int game_event(struct event* event,void* game){
|
|||||||
}
|
}
|
||||||
// Draw world state
|
// Draw world state
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
void draw_game(struct game *game){
|
||||||
// Draw cat
|
// Draw cat
|
||||||
|
printf("Cat position: (%d, %d)\n", game->catx, game->caty);
|
||||||
|
|
||||||
|
|
||||||
clear_screen();
|
clear_screen();
|
||||||
set_color_cell('c',state->catx_position,state->caty_position,COLOR_YELLOW,COLOR_RED);
|
set_color_cell('c',state->catx_position,state->caty_position,COLOR_YELLOW,COLOR_RED);
|
||||||
set_color_cell('-',state->catx_position-1,state->caty_position,COLOR_YELLOW,COLOR_GREEN);
|
set_color_cell('-',state->catx_position-1,state->caty_position,COLOR_YELLOW,COLOR_GREEN);
|
||||||
//set_cell('c',state->catx_position,state->caty_position);
|
//set_cell('c',state->catx_position,state->caty_position);
|
||||||
// Draw mouse
|
// Draw mouse
|
||||||
set_cell('m',state->mousex,state->mousey);
|
int alive_count = 0;
|
||||||
set_message( state->message,1,0);
|
for (int i = 0; i < MOUSE_COUNT; i++) {
|
||||||
|
if (game->mouse_state[i] == 0) { // Mouse is alive
|
||||||
|
printf("Mouse %d position: (%d, %d)\n", i, game->mousex[i], game->mousey[i]);
|
||||||
|
alive_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alive_count == 0) {
|
||||||
|
printf("All mice are eaten! Game over.\n");
|
||||||
|
} else {
|
||||||
|
printf("Number of alive mice: %d\n", alive_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//set_cell('m',state->mousex,state->mousey);
|
||||||
|
//set_message( state->message,1,0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user