Game For ECE 2035
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Diff: main.cpp
- Revision:
- 8:fcc333a8f9e1
- Parent:
- 7:862062ffca62
- Child:
- 9:cbb9cfb1f6c5
diff -r 862062ffca62 -r fcc333a8f9e1 main.cpp --- a/main.cpp Sat Nov 20 03:37:50 2021 +0000 +++ b/main.cpp Sat Nov 20 03:57:56 2021 +0000 @@ -24,6 +24,7 @@ int has_key; int spell; int god; + int won; // You can add other properties for the player here } Player; @@ -143,7 +144,7 @@ npc_speech2(); } - if(east->type == NPC||west->type == NPC||north->type == NPC||south->type == NPC){ + if(east->type == NPC||west->type == NPC||north->type == NPC||south->type == NPC && Player.has_key == 0 ){ npc_speech1(); } @@ -161,6 +162,10 @@ init_main_map(); } + if((north->type == DOOR||south->type == DOOR||east->type == DOOR||west->type == DOOR)&&Player.has_key == 1){ + Player.won = door_open(); + } + } break; case MENU_BUTTON: { @@ -322,6 +327,10 @@ // 3. Update game (update_game) update_game(action); // 3b. Check for game over + if(Player.won == 1){ + draw_gameover(); + break; + } // 4. Draw frame (draw_game) draw_game(true);