Update 'a3/game.c'
This commit is contained in:
parent
c1500bf3d4
commit
27d0920937
19
a3/game.c
19
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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user