Update 'a3/game.c'
This commit is contained in:
parent
948ee5629d
commit
3387b1606c
26
a3/game.c
26
a3/game.c
@ -33,6 +33,19 @@ int game_event(struct event* event,void* game){
|
|||||||
}
|
}
|
||||||
// Read game variable and update the eventstate
|
// 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 ?
|
// Is mouse caught ?
|
||||||
if ((state->caty_position == state->mousey) && (state->catx_position == state->mousex)){
|
if ((state->caty_position == state->mousey) && (state->catx_position == state->mousex)){
|
||||||
clear_screen();
|
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_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);
|
|
||||||
|
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);
|
set_message( state->message,1,0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user