Game For ECE 2035

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Revision:
11:6cd02a8539d1
Parent:
10:e18685911e84
Child:
12:116a4cc85b16
--- a/main.cpp	Wed Dec 01 22:07:24 2021 +0000
+++ b/main.cpp	Thu Dec 02 06:24:22 2021 +0000
@@ -33,6 +33,7 @@
     int god;
     int won;
     int HP,MP;
+    int talked;
     // You can add other properties for the player here
 } Player;
 
@@ -104,10 +105,8 @@
 #define FULL_DRAW 2
 int update_game(int action)
 {
-   
-         
+     //walk_goblin(0);    
             
-    //walk_npc();
     
     
  // Save player previous location before updating
@@ -161,25 +160,49 @@
 
             if(east->type == NPC||west->type == NPC||north->type == NPC||south->type == NPC && Player.has_key == 0 ) {
                 npc_speech1();
+                Player.talked = 1;
             }
 
             if(north->type == PORTAL||south->type == PORTAL||east->type == PORTAL||west->type == PORTAL) {
-                init_dung();
+                 set_active_map(1);
                 Player.x = Player.y = 7;
             }
+            
+            if((east->type == ENEMY||west->type == ENEMY||north->type == ENEMY||south->type == ENEMY)&& Player.spell == EARTH) {
+                map_delete(13,14);
+            }
+            
+            if((east->type == ENEMY||west->type == ENEMY||north->type == ENEMY||south->type == ENEMY)&& Player.spell == FIRE) {
+                Player.HP-=2;
+                map_delete(5,10);
+            }
+            
+            if((east->type == ENEMY||west->type == ENEMY||north->type == ENEMY||south->type == ENEMY)&& Player.spell == WATER) {
+                Player.HP-=10;
+                Player.x--;
+                Player.y--;
+            }
+            
 
             if((north->type == DRAGON||south->type == DRAGON||east->type == DRAGON||west->type == DRAGON )&& Player.spell == WATER) {
                 slay_dragon();
                 Player.has_key = 1;
+                walk_goblin(0);
             }
 
             if(north->type == PORTAl||south->type == PORTAl||east->type == PORTAl||west->type == PORTAl) {
-                init_main_map();
+                set_active_map(0);
+                Player.x=20;
+                Player.y = 36;
             }
 
             if((north->type == DOOR||south->type == DOOR||east->type == DOOR||west->type == DOOR)&&Player.has_key == 1) {
                 Player.won = door_open();
             }
+            
+            if((north->type == DOOR||south->type == DOOR||east->type == DOOR||west->type == DOOR)&&Player.has_key == 0) {
+                door_locked();
+            }
 
             if((north->type == PLANT||south->type == PLANT||east->type == PLANT||west->type == PLANT||curr->type == PLANT)&&
                     (north->data == FRUIT||south->data == FRUIT||east->data == FRUIT||west->data == FRUIT||curr->data == FRUIT)) {
@@ -206,6 +229,7 @@
         case MENU_BUTTON: {
             init_spells();
             Player.spell = spell();
+            Player.MP -= 10;
         }
         break;
         case GOD_MODE: {
@@ -224,8 +248,6 @@
             break;
     }
     
-
-    //delete_npc(9,9);
     
     return NO_RESULT;
 
@@ -299,7 +321,7 @@
 {
     // "Random" plants
     Map* map = set_active_map(0);
-    for(int i = map_width() + 3; i < map_area(); i += 39) {
+    for(int i = map_width() + 9; i < map_area(); i += 39) {
         add_plant(i % map_width(), i / map_width());
     }
     pc.printf("plants\r\n");
@@ -321,10 +343,11 @@
 
 
 
-    set_npc(9,9);
-
-    //add_chest(10,10);
-
+    add_npc(9,9);
+    
+    add_npc2(30,30);
+    
+    
     add_door(26,12);
 
     add_portal(20,35);
@@ -332,7 +355,6 @@
     print_map();
 }
 
-
 /**
  * Program entry point! This is where it all begins.
  * This function orchestrates all the parts of the game. Most of your
@@ -354,16 +376,19 @@
     // Initialize the maps
     maps_init();
     init_main_map();
+    init_dung();
+    
 
     // Initialize game state
     set_active_map(0);
     Player.x = Player.y = 5;
+    //Player.spell = NULL;
 
     draw_start();
 
-    //wave_file = fopen("/sd/godfather.wav","r");
-    //waver.play(wave_file);
-    //fclose(wave_file);
+    wave_file = fopen("/sd/godfather.wav","r");
+    waver.play(wave_file);
+    fclose(wave_file);
 
     while(1) {