Finished V1

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Files at this revision

API Documentation at this revision

Comitter:
trich9
Date:
Sun Nov 24 03:22:35 2019 +0000
Parent:
4:2297a714936f
Commit message:
finished V1

Changed in this revision

globals.h Show annotated file Show diff for this revision Revisions of this file
graphics.cpp Show annotated file Show diff for this revision Revisions of this file
graphics.h Show annotated file Show diff for this revision Revisions of this file
hardware.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
map.cpp Show annotated file Show diff for this revision Revisions of this file
map.h Show annotated file Show diff for this revision Revisions of this file
speech.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/globals.h	Tue Nov 19 16:53:47 2019 +0000
+++ b/globals.h	Sun Nov 24 03:22:35 2019 +0000
@@ -6,9 +6,9 @@
 #define GLOBAL_H
 
 //MYCODE
-#define NUMBUCKETS 75
+#define NUMBUCKETS 100
 #define MAPWIDTH 75
-#define MAPHEIGHT 75
+#define MAPHEIGHT 50
 
 #define MAP2WIDTH   20
 #define MAP2HEIGHT  10
@@ -19,6 +19,8 @@
 #include "MMA8452.h"
 #include "uLCD_4DGL.h"
 #include "SDFileSystem.h"
+//MYCODE
+
 
 // Declare the hardware interface objects
 extern uLCD_4DGL uLCD;      // LCD Screen
--- a/graphics.cpp	Tue Nov 19 16:53:47 2019 +0000
+++ b/graphics.cpp	Sun Nov 24 03:22:35 2019 +0000
@@ -4,14 +4,20 @@
 
 
 
-void draw_player(int u, int v, int key)
+void draw_player(int u, int v, int key, int needBoat)
 {
     //OGCODE
     //uLCD.filled_rectangle(u, v, u+11, v+11, RED);
     
     //MYCODE
-    char playerSprite[122] = "0000000000000QQQQQQQ0000QUUUUUQ0000QUEUEUQ0000QUUUUUQ000000TUT0000000TUUUT000000TWWWT000000TUUUT000000TUTUT000000TUTUT000";
-    draw_img(u,v, playerSprite);
+    if(needBoat == 0){
+        char playerSprite[122] = "0000000000000QQQQQQQ0000QUUUUUQ0000QUEUEUQ0000QUUUUUQ000000TUT0000000TUUUT000000TWWWT000000TUUUT000000TUTUT000000TUTUT000";
+        draw_img(u,v, playerSprite);
+    }
+    else{
+        char playerBoatSprite[122] = "OOOOOOOOOOOOOOODDDOOOOOOODDDDDOOOOODDDDDDDOOOODUUUUUDOOOODUEUEUDOOOODUUUUUDOOOODDDDDDDOOOODDDDDDDOOOODDDDDDDOOOOOOOOOOOOO";
+        draw_img(u,v, playerBoatSprite);
+    }
 }
 
 #define YELLOW 0xFFFF00
@@ -23,6 +29,11 @@
 #define PCOAT  0xF7C6C6
 #define PSKIN  0xFF9900
 #define WGRAY  0xC9C9C9
+#define PINK   0xE009EB
+#define LBWTR  0x00C4FF
+#define DBWTR  0x0C667D
+#define RGRAY  0x242424
+
 
 
 //MYCODE
@@ -48,6 +59,13 @@
         
         //WALL
         else if (img[i] == 'I') colors[i] = WGRAY;
+        //NPC
+        else if (img[i] == 'A') colors[i] = PINK;
+        //WATER
+        else if (img[i] == 'O') colors[i] = LBWTR;
+        else if (img[i] == 'P') colors[i] = DBWTR;
+        //ROCKS
+        else if (img[i] == 'S') colors[i] = RGRAY;
         //ENDMYCODE
         else colors[i] = BLACK;
     }
@@ -61,6 +79,11 @@
     uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
 }
 
+void draw_expPnt(int u, int v){
+    char expPntSprite[122] = "00YYYYYYY00000YYYYY000000YYYYY000000YYYYY0000000YYY00000000YYY00000000YYY00000000000000000000Y000000000YYY000000000Y00000";
+    draw_img(u,v, expPntSprite);
+}
+
 void draw_wall(int u, int v)
 {
     //OGCODE
@@ -73,13 +96,18 @@
 
 void draw_plant(int u, int v)
 {
-    uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
+    //OGCODE
+    //uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
+    char plantSprite[122] = "00000G000000000GGG0000000GGGGG00000GGGGGGG000GGGGGGGGG00GGGGGGGGG0GGGGGGGGGGG0000DDD00000000DDD00000000DDD00000000DDD0000";
+    draw_img(u,v, plantSprite);  
 }
 
 //MYCODE
 void draw_NPC(int u, int v)
 {
-    uLCD.filled_rectangle(u,v,u+10,v+10, YELLOW);    
+    //uLCD.filled_rectangle(u,v,u+10,v+10, YELLOW); 
+    char NPCSprite[122] = "00000000000000GGGGG00000GGGGGGG000GGAGGGAGG00GGAGGGAGG00GGGGGGGGG00GGGGGGGGG00GGAGGGAGG000GGAAAGG00000GGGGG00000000000000";
+    draw_img(u,v, NPCSprite);     
 }
 
 void draw_ladder(int u, int v){
@@ -88,6 +116,62 @@
     draw_img(u,v, ladderSprite);   
 }
 
+void draw_key(int u, int v){
+    char keySprite[122] = "000YYYYY0000YYYYYYYY000YYYYYYYY000YYYYYYYY00000YYYYY00000000Y0000000000Y0000000YYYY0000000000Y0000000YYYY0000000000Y00000";
+    draw_img(u,v,keySprite);   
+}
+
+void draw_sonar(int u, int v){
+    char sonarSprite[122] = "00GGGGGGG000G0000000G0G000000000G00GGGGGGG000G0000000G00000GGG0000000G000G0000000000000000000Y000000000YYY0000000YYYYY000";
+    draw_img(u,v,sonarSprite);   
+}
+
+void draw_treasure(int u, int v){
+    char treasureSprite[122] = "000000000000YYDDDDDYY0YDDDDDDDDDYYDDDYYYDDDYIIIIYIYIIIIDDDDYYYDDDDDDDDDDDDDDDDDDDDDDDDDDIDDDDDDDDDIIIDDDDDDDII00000000000";
+    draw_img(u,v,treasureSprite);   
+}
+
+void draw_water(int u, int v){
+    char waterSprite[122] = "OOOOOOOOOOOOOOPOOOPOOOOOOPOOOPOOOOOPPOOPPOOOOOPOOOPOOOOOOPOOOPOOOOOOOOPOOOPOOOOOOPOOOPOOOOOPPOOPPOOOOOPOOOPOOOOOOOOOOOOOO";
+    draw_img(u,v,waterSprite);  
+}
+
+//sparkle1
+void draw_waterS1(int u, int v){
+    char waterS1Sprite[122] = "OOOOOOOOOOOOOOYOOOPOOOOOYYYOOPOOOOOPYOOPPOOOOOPOOOPOOOOOOPOOOPOOOOOOOOPOOOPOOOOOOPOYOPOOOOOPPOOPPOOOOOPOOOPOOOOOOOOOOOOOO";
+    draw_img(u,v,waterS1Sprite);  
+}
+
+void draw_waterS2(int u, int v){
+    char waterS2Sprite[122] = "OOOOOOOOOOOOOOOOOOPOOOOOOYOOOPOOOOOPOOOPPOOOOOPOOOPOOOOOOPOOOPOOOOOOOOPOYOPOOOOOOPYYYPOOOOOPPOYPPOOOOOPOOOPOOOOOOOOOOOOOO";
+    draw_img(u,v,waterS2Sprite);  
+}
+
+void draw_rock(int u, int v){
+    char rockSprite[122] = "00000000000000ISSI000000ISSIII0000IISIIIIS00ISIIIIISSI0ISIIIIISIISIISIISISIISISIIISIISSISSIISIISSISSIIISIISIIS0IIISSSIIII";
+    draw_img(u,v,rockSprite);  
+}
+
+
+
+void draw_gate(int u, int v){
+    char gateSprite[122] = "00000000000000YYYYY000000YY0YY000000Y000Y000YYYY000YYYYYYYYY0YYYYYYYYYY0YYYYY000Y000Y000000YY0YY000000YYYYY00000000000000";
+    draw_img(u,v,gateSprite);  
+}
+
+void draw_prisoner(int u, int v){
+    char prisonerSprite[122] = "IIIIIIIIIIIIWWPWWWPWWIIIIPIIIPIIIIWWPWWWPWWIIIIIIIIIIIIIWWWWWWWWWIIIIIIIIIIIIIWWPPPPPWWIIIIPPPPPIIIIWWWWWWWWWIIIIIIIIIIII";
+    draw_img(u,v,prisonerSprite);  
+}
+
+//"IIIIIIIIIIIIWWPWWWPWWIIIIPIIIPIIIIWWPWWWPWWIIIIIIIIIIIIIWWWWWWWWWIIIIIIIIIIIIIWWPPPPPWWIIIIPPPPPIIIIWWWWWWWWWIIIIIIIIIIII";
+
+void draw_wood(int u, int v)
+{
+    // Fill a tile with blackness
+    uLCD.filled_rectangle(u, v, u+10, v+10, BROWN);
+}
+
 void draw_upper_status(int playerX, int playerY)
 {
     // Draw bottom border of status bar
--- a/graphics.h	Tue Nov 19 16:53:47 2019 +0000
+++ b/graphics.h	Sun Nov 24 03:22:35 2019 +0000
@@ -5,7 +5,7 @@
 /**
  * Draws the player. This depends on the player state, so it is not a DrawFunc.
  */
-void draw_player(int u, int v, int key);
+void draw_player(int u, int v, int key, int needBoat);
 
 /**
  * Takes a string image and draws it to the screen. The string is 121 characters
@@ -33,7 +33,18 @@
 //MYCODE
 void draw_NPC(int u, int v);
 void draw_ladder(int u, int v);
+void draw_key(int u, int v);
+void draw_sonar(int u, int v);
+void draw_treasure(int u, int v);
+void draw_gate(int u, int v);
+void draw_water(int u, int v);
+void draw_waterS1(int u, int v);
+void draw_waterS2(int u, int v);
+void draw_rock(int u, int v);
+void draw_wood(int u, int v);
+void draw_prisoner(int u, int v);
 
+void draw_expPnt(int u, int v);
 /**
  * Draw the upper status bar.
  */
--- a/hardware.cpp	Tue Nov 19 16:53:47 2019 +0000
+++ b/hardware.cpp	Sun Nov 24 03:22:35 2019 +0000
@@ -17,7 +17,7 @@
 DigitalIn button2(p22);
 DigitalIn button3(p23);
 AnalogOut DACout(p18);                  // Speaker (pin)
-PwmOut speaker(p25);                    //MYCODE changed from 26
+PwmOut speaker(p26);                    //MYCODE changed from 26
 wave_player waver(&DACout);
 
 // Some hardware also needs to have functions called before it will set up
--- a/main.cpp	Tue Nov 19 16:53:47 2019 +0000
+++ b/main.cpp	Sun Nov 24 03:22:35 2019 +0000
@@ -5,6 +5,7 @@
 #include "graphics.h"
 #include "speech.h"
 
+
 // Functions in this file
 int get_action (GameInputs inputs);
 int update_game (int action);
@@ -18,8 +19,10 @@
 int        action;
 int        gUpdate;
 int        omnipotent;
+int        hasSonar;
 
 int dialogueNumNPC = 0;
+int dialogueNumPris = 0;
 //animationstuff
 int updateCount = 0;
 
@@ -28,6 +31,9 @@
 int NPCy = 5;
 int walkCycleNPC = 0;
 
+//speech
+char *talk1 = "";
+
 int go_up(int x, int y);
 int go_down(int x, int y);
 int go_right(int x, int y);
@@ -37,6 +43,26 @@
 void animation_update();
 void moveNPC();
 
+void spawnTreasure();
+void spawnLakeTreasure();
+void treasureSparkle();
+int fakeLakeTreasure = 1;
+int fakeTreasure = 1;
+int hasBoat = 0;
+int treasureX;
+int treasureY;
+
+int lakeTreasureX;
+int lakeTreasureY;
+
+int needBoat = 0;
+void checkNeedBoat();
+
+void startScreen();
+void endScreen();
+
+void pickUpSound();
+void ladderSound();
 
 
 
@@ -66,7 +92,7 @@
 #define GO_RIGHT 4
 #define GO_UP 5
 #define GO_DOWN 6
-#define ACTION_BUTTON 7
+//#define ACTION_BUTTON 7
 int get_action(GameInputs inputs)
 {
     //MYCODE
@@ -173,37 +199,44 @@
 //MYCODE
 int go_up(int x, int y){
     MapItem *northItem = get_north(x, y);
-    if(northItem->walkable || omnipotent){
+    if(northItem->walkable || omnipotent || (hasBoat && northItem->type == water)){
         Player.y--;
+        
+        checkNeedBoat();
         return 1;    
     }    
     return 0;
 }
 int go_down(int x, int y){
     MapItem *southItem = get_south(x, y);
-    if(southItem->walkable || omnipotent){
+    if(southItem->walkable || omnipotent || (hasBoat && southItem->type == water)){
         Player.y++;
+        checkNeedBoat();
         return 1;    
     }    
     return 0;
 }
 int go_left(int x, int y){
     MapItem *westItem = get_west(x, y);
-    if(westItem->walkable || omnipotent){
+    if(westItem->walkable || omnipotent || (hasBoat && westItem->type == water)){
         Player.x--;
+        checkNeedBoat();
         return 1;    
     }    
     return 0;
 }
 int go_right(int x, int y){
     MapItem *eastItem = get_east(x, y);
-    if(eastItem->walkable || omnipotent){
+    if(eastItem->walkable || omnipotent || (hasBoat && eastItem->type == water)){
         Player.x++;
+        checkNeedBoat();
         return 1;    
     }    
     return 0;
 }
 
+// || (hasBoat && eastItem->type == water)
+
 int action_button(int x, int y){
     MapItem *eastItem = get_east(x, y);
     MapItem *westItem = get_west(x, y);
@@ -217,28 +250,186 @@
     if(eastItem -> type == NPC || westItem -> type == NPC || northItem  -> type == NPC || southItem -> type == NPC || hereItem -> type == NPC){
         
         if(dialogueNumNPC == 0){
-            char *talk1 = "";
-                         //1234567890123456789012345678901234567901234567890
-            char *talk2 = "Go down that     ladder above me to get a sonar";
+                         //1234567890123456X8901234567890123X5679012345678901X1234567890
+            char *talk2 = "There's a ladder SOUTH of here    where you can geta sonar.";
             speech(talk1, talk2);
-            add_ladder(6, 3);
+            add_ladder(8, 40);
             dialogueNumNPC = 1;
-
+            
         }
         else if(dialogueNumNPC == 1){
-            char *talk1 = "";
-                         //1234567890123456789012345678901234567901234567890
-            char *talk2 = "*ahem* I said go down that ladder right above me.";
+                         //1234567890123456X8901234567890123X567901234567890
+            char *talk2 = "It's around the  lake, between    two rocks.";
             speech(talk1, talk2);
+            
         }
-        
+       //map_erase(NPCx,NPCy-1); 
         
     }
     //ladder interaction
-     if(eastItem -> type == ladder || westItem -> type == ladder || northItem  -> type == ladder || southItem -> type == ladder || hereItem -> type == ladder){
+    else if(eastItem -> type == ladder || westItem -> type == ladder || northItem  -> type == ladder || southItem -> type == ladder || hereItem -> type == ladder){
         //add_ladder(8, 8);
+        
+        ladderSound();
+        map_erase(8, 40);    
         init_map2();
     }
+    //sonar interation
+    else if(eastItem -> type == sonar || westItem -> type == sonar || northItem  -> type == sonar || southItem -> type == sonar || hereItem -> type == sonar){
+        
+        pickUpSound();
+                     //1234567890123456789012345678901234567901234567890
+        char *talk2 = "You found the    sonar!!!";
+        speech(talk1, talk2);
+        
+        map_erase(14, 8);       //erase the sonar
+        init_main_map();        //switch back to main map
+        Player.x = 8;           //CHANGE to cords of new ladder when done
+        Player.y = 40;
+        
+        spawnTreasure();        //spawn the treasure
+        hasSonar = 1;           //allow player to use sonar
+    }
+    
+    else if(eastItem -> type == keyItem || westItem -> type == keyItem || northItem  -> type == keyItem || southItem -> type == keyItem || hereItem -> type == keyItem){
+        
+        pickUpSound();
+                     //1234567890123456789012345678901234567901234567890
+        char *talk2 = "You found a key. I wonder what it opens?";
+        speech(talk1, talk2);
+        map_erase(18, 8);
+        Player.has_key = 1;
+    }
+    
+    else if(eastItem -> type == treasure || westItem -> type == treasure || northItem  -> type == treasure || southItem -> type == treasure || hereItem -> type == treasure){
+        //add_ladder(8, 8);
+        if(fakeTreasure == 1){//first treasure found so it is fake
+                         //1234567890123456789012345678901234567901234567890
+            char *talk2 = "That treasure    was fake.";
+            speech(talk1, talk2);
+            
+            map_erase(treasureX, treasureY);
+            spawnTreasure();
+            fakeTreasure = 0;
+        }
+        else{ //do a game over screen
+            endScreen();  
+        }
+    }
+    
+    //gate stuff
+     else if(eastItem -> type == gate || westItem -> type == gate || northItem  -> type == gate || southItem -> type == gate || hereItem -> type == gate){
+           if(Player.has_key){
+                pickUpSound();
+                             //123456789012345678901234567890123X567901234567890
+                char *talk2 = "You used your keyto unlock the    gate."; 
+                speech(talk1, talk2);
+                
+                map_erase(33, 5);
+           }
+           else{
+               char *talk2 = "It's locked."; 
+               speech(talk1, talk2);
+           }
+     }
+     
+     else if(eastItem -> type == prisoner || westItem -> type == prisoner || northItem  -> type == prisoner || southItem -> type == prisoner || hereItem -> type == prisoner){
+            if(dialogueNumPris == 0){
+                             //1234567890123456X8901234567890123X5679012345678901X1234567890123456X1234567890123456X1234567890123456X
+                char *talk2 = "Hey... you just  like freed me    from this jail...";
+                speech(talk1, talk2);
+                             //1234567890123456X8901234567890123X5679012345678901X1234567890123456X1234567890123456X1234567890123456X
+                char *talk3 = "I was going to   use this BOAT to bust out... But  I guess you can  have it now.";
+                speech(talk1, talk3);
+                
+                pickUpSound();
+                char *talk4 = "You got a BOAT!  You can travel   over water now!";
+                speech(talk1, talk4);
+                
+                spawnLakeTreasure();
+                
+                hasBoat = 1;
+                dialogueNumPris = 1;
+                map_erase(33,1);
+            }
+            else if(dialogueNumPris == 1){
+                            //1234567890123456X8901234567890123X5679012345678901X1234567890123456X1234567890123456X1234567890123456X
+                char *talk2 = "Kinda forgot why I made a boat in the first        place...";
+                speech(talk1, talk2);
+                             //1234567890123456X8901234567890123X5679012345678901X1234567890123456X
+                char *talk3 = "Something to do  with a lake and  treasure... "; 
+                speech(talk1, talk3);   
+            }
+            
+            
+            
+     }
+    
+    
+    //no items found so give the speech based on whether he has the sonar or not
+    else{
+        if(!hasSonar){
+                         //1234567890123456X8901234567890123X567901234567890
+            char *talk2 = "You do not have  the sonar.";  
+            speech(talk1, talk2);
+        }
+        else{
+            
+            //char buffer[50];
+            //sprintf(buffer, "%d, %d", treasureX, treasureY);
+            if(get_here(Player.x, Player.y) -> type != water){//player is in the water
+                              //1234567890123456X8901234567890123X567901234567890
+                char *talk2 = "The sonar says:";
+                char *talkWest = "West";
+                char *talkEast = "East";
+                char *talkNorth = "North";
+                char *talkSouth = "South";
+                speech(talk1, talk2);
+                
+                if(treasureX > Player.x) speech(talk1, talkEast);
+                if(treasureX < Player.x) speech(talk1, talkWest);
+                if(treasureY > Player.y) speech(talk1, talkSouth);
+                if(treasureY < Player.y) speech(talk1, talkNorth);
+            }
+            else{
+                if(Player.x == lakeTreasureX && Player.y == lakeTreasureY){//player is on the treasure
+                                 //1234567890123456X8901234567890123X567901234567890
+                    char *talk2 = "There's          something down   here!";
+                    speech(talk1, talk2);
+                    
+                    if(fakeLakeTreasure){//tres is fake
+                                     //1234567890123456X8901234567890123X567901234567890
+                        char *talk3 = "It's just an old boot :(";
+                        speech(talk1, talk3);
+                        fakeLakeTreasure = 0;
+                        spawnLakeTreasure();
+                    }
+                    else{//tres is real
+                                     //1234567890123456X8901234567890123X1234567890123456X1234567890123456X
+                        char *talk3 = "It's a giant     treasure chest!  You gleefully    throw it onto theshore!";
+                        speech(talk1, talk3);
+                        
+                        fakeTreasure = 0;
+                        add_treasure(13,11);
+                    }
+                    
+                }
+                else{
+                    char *talk2 = "The sonar says:";
+                    speech(talk1, talk2);
+                                 //1234567890123456X8901234567890123X567901234567890
+                    char *talk3 = "Look for a       shimmer in the   sea...";
+                    speech(talk1, talk3);
+                    //char buffer[50];
+                    //sprintf(buffer, "%d, %d", lakeTreasureX, lakeTreasureY);
+                    //speech(talk1, buffer);
+                    treasureSparkle();
+                }
+            }
+        }
+        
+    }
+    
     return 1;
 }
 
@@ -276,7 +467,7 @@
             DrawFunc draw = NULL;
             if (init && i == 0 && j == 0) // Only draw the player on init
             {
-                draw_player(u, v, Player.has_key);
+                draw_player(u, v, Player.has_key, needBoat);
                 continue;
             }
             else if (x >= 0 && y >= 0 && x < map_width() && y < map_height()) // Current (i,j) in the map
@@ -323,12 +514,25 @@
 {
     // "Random" plants
     Map* map = set_active_map(0);
+    
+    /*OGCODE
     for(int i = map_width() + 3; i < map_area(); i += 39)
     {
         add_plant(i % map_width(), i / map_width());
     }
     pc.printf("plants\r\n");
-        
+    */
+    
+    //adds plants in random locations
+    int numberOfPlants = 75;
+    
+    srand (time(NULL));
+    while(numberOfPlants > 0){
+        add_plant((rand()%70 + 2), (rand()%45+2));\
+        numberOfPlants--;   
+    }
+    
+    
     pc.printf("Adding walls!\r\n");
     add_wall(0,              0,              HORIZONTAL, map_width());
     add_wall(0,              map_height()-1, HORIZONTAL, map_width());
@@ -336,9 +540,54 @@
     add_wall(map_width()-1,  0,              VERTICAL,   map_height());
     pc.printf("Walls done!\r\n");
     
-    
+
     //MYCODE
     add_NPC(6, 5);
+    
+    
+    //TESTING
+    //ENDTESTING
+    //lake1
+    add_water(4, 8, HORIZONTAL, 5);
+    add_water(3, 9, HORIZONTAL, 7);
+    add_water(3, 10, HORIZONTAL, 9);
+    add_water(3, 11, HORIZONTAL, 9);
+    add_water(3, 12, HORIZONTAL, 9);
+    add_water(3, 13, HORIZONTAL, 7);
+    add_water(4, 14, HORIZONTAL, 5);
+    
+    
+    //ROCKS!!!
+    
+    add_rock(4, 39, HORIZONTAL, 2);
+    add_rock(3, 40, HORIZONTAL, 3);
+    
+    add_rock(9, 39, HORIZONTAL, 2);
+    add_rock(9, 40, HORIZONTAL, 3);
+
+    //WOOD "HOUSE"
+    add_wood(30, 1, HORIZONTAL, 1);
+    add_wood(36, 1, HORIZONTAL, 1);
+    
+    add_wood(30, 2, HORIZONTAL, 1);
+    add_wood(36, 2, HORIZONTAL, 1);
+    
+    add_wood(30, 3, HORIZONTAL, 1);
+    add_wood(36, 3, HORIZONTAL, 1);
+    
+    add_wood(30, 4, HORIZONTAL, 1);
+    add_wood(36, 4, HORIZONTAL, 1);
+    
+    add_wood(30, 5, HORIZONTAL, 3);
+    add_wood(34, 5, HORIZONTAL, 3);
+    
+    add_gate(33,5);
+    
+    add_prisoner(33, 2);
+    add_expPnt(33, 1);
+    
+    //TESTING
+    
     print_map();
 }
 
@@ -352,7 +601,9 @@
 {
     // First things first: initialize hardware
     ASSERT_P(hardware_init() == ERROR_NONE, "Hardware init failed!");
-
+    
+    //MYCODE
+    startScreen();
     // Initialize the maps
     maps_init();
     init_main_map();
@@ -363,6 +614,7 @@
     
     //MYCODE
     omnipotent = 0;
+    hasSonar = 0;
     
     // Initial drawing
     draw_game(true);
@@ -413,10 +665,55 @@
     add_wall(map_width()-1,  0,              VERTICAL,   map_height());
     pc.printf("Walls done!\r\n");
     
+    //INTERIOR WALLS
+    add_wall(4, 1, VERTICAL, 5);
+    
+    add_wall(8, 1, VERTICAL, 3);
+    add_wall(8, 5, VERTICAL, 3);
+    
+    add_wall(9, 5, HORIZONTAL, 4);
+    add_wall(12, 5, VERTICAL, 4);
+    
+    add_wall(9, 5, HORIZONTAL, 4);
+    add_wall(12, 2, VERTICAL, 9);
+    
+    add_wall(15, 4, VERTICAL, 9);
+    add_wall(16, 4, VERTICAL, 9);
+    
+    add_sonar(14, 8);
+    add_key(18, 8);
     
     print_map();
 }
 
+//STARTSCREEN
+void startScreen(){
+    uLCD.filled_rectangle(0, 0, 128, 128, BLACK);
+    
+    uLCD.locate(2, 1);
+    uLCD.color(WHITE);
+    uLCD.text_width(1);
+    uLCD.text_height(1);
+            
+    uLCD.printf("   GET THAT\n    TREASURE!!\n\n     Press The\n   Action Button\n     To START");
+            
+    uLCD.filled_rectangle(0, 0, 128, 2, BLUE);//top
+    uLCD.filled_rectangle(0, 0, 2, 128, BLUE);//bottom
+    
+    uLCD.filled_rectangle(0, 126, 128, 128, BLUE);
+    uLCD.filled_rectangle(126, 0, 128, 128, BLUE); 
+    
+    GameInputs startInputs = read_inputs();
+    while(startInputs.b3){//while button not pressed
+        startInputs = read_inputs();        
+    }
+    
+    uLCD.filled_rectangle(0, 0, 128, 128, BLACK);
+    
+}
+
+
+
 //once every 10 in game cycles the aniamtions and npc movements will happen
 void animation_update(){
     updateCount++;
@@ -429,6 +726,9 @@
 void moveNPC(){
     if(map_width() == 75){
         map_erase(NPCx, NPCy);
+        
+        
+        map_erase(NPCx, NPCy-1);
         //walkCycleNPC = 0 => go right
         //wCNPC = 1 => go left
         if(NPCx < 10 && !walkCycleNPC) NPCx++;
@@ -438,6 +738,257 @@
         else if(NPCx == 2) walkCycleNPC = 0;
             
         add_NPC(NPCx, NPCy);  
+        if(dialogueNumNPC == 0) add_expPnt(NPCx,NPCy-1);//NPC has something important to say
+        
     }
      
 }
+
+void spawnTreasure(){
+    
+        srand (time(NULL));
+        treasureX = (rand()%45) + 25;   //rand x cord for treasure
+        treasureY = (rand()%30) + 15;   //rand y cord for treasure
+        
+        add_treasure(treasureX, treasureY);
+}
+
+void spawnLakeTreasure(){
+    
+        srand (time(NULL));
+        lakeTreasureX = (rand()%5) + 4;   //rand x cord for treasure
+        lakeTreasureY = (rand()%7) + 8;   //rand y cord for treasure
+        
+}
+
+void treasureSparkle(){
+        
+        add_waterS1(lakeTreasureX, lakeTreasureY);
+        draw_game(FULL_DRAW);
+        wait_ms(500);
+        
+        add_waterS2(lakeTreasureX, lakeTreasureY);
+        draw_game(FULL_DRAW);
+        wait_ms(500);
+        add_water(lakeTreasureX, lakeTreasureY, HORIZONTAL, 1);
+}
+
+void checkNeedBoat(){
+    if(get_here(Player.x, Player.y) -> type == water){
+      needBoat = 1;   
+    }
+    else{
+      needBoat = 0;   
+    }
+}
+
+
+void pickUpSound(){
+    speaker.period(1.0/98);
+    speaker = 0.01;
+    wait_ms(100);
+    speaker = 0;
+    wait_ms(50);  
+    
+    speaker.period(1.0/110);
+    speaker = 0.01;
+    wait_ms(100);
+    speaker = 0;
+    wait_ms(50);
+    
+    speaker.period(1.0/123);
+    speaker = 0.01;
+    wait_ms(100);
+    speaker = 0;
+    wait_ms(50); 
+    
+    speaker.period(1.0/130);
+    speaker = 0.01;
+    wait_ms(100);
+    speaker = 0;
+}
+
+void ladderSound(){
+    speaker.period(1.0/130);
+    speaker = 0.01;
+    wait_ms(100);
+    speaker = 0;
+    wait_ms(50);  
+    
+    speaker.period(1.0/123);
+    speaker = 0.01;
+    wait_ms(100);
+    speaker = 0;
+    wait_ms(50);
+    
+    speaker.period(1.0/110);
+    speaker = 0.01;
+    wait_ms(100);
+    speaker = 0;
+    wait_ms(50); 
+    
+    speaker.period(1.0/98);
+    speaker = 0.01;
+    wait_ms(100);
+    speaker = 0;
+}
+
+void endScreen(){
+            uLCD.filled_rectangle(0, 0, 128, 128, BLACK);
+    
+            
+            
+            uLCD.locate(2, 1);
+            uLCD.color(WHITE);
+            uLCD.text_width(1);
+            uLCD.text_height(1);
+            
+            uLCD.printf("   YOU WON!\n\n      Thanks\n       For\n     Playing!!");
+            
+            uLCD.filled_rectangle(0, 0, 128, 2, BLUE);//top
+            uLCD.filled_rectangle(0, 0, 2, 128, BLUE);//bottom
+    
+            uLCD.filled_rectangle(0, 126, 128, 128, BLUE);
+            uLCD.filled_rectangle(126, 0, 128, 128, BLUE); 
+            
+            
+            
+                
+           int nWait = 100;
+           //int speakerVolume = 0.1;
+           while(true){
+                //MEME
+                
+                //intro1
+                
+                speaker.period(1.0/369);
+                speaker = 0.01;
+                wait_ms(350);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/293);
+                wait_ms(350);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/293);
+                wait_ms(100);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/329);
+                wait_ms(100);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/349);
+                wait_ms(200);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/329);
+                wait_ms(250);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/293);
+                wait_ms(200);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/277);
+                wait_ms(250);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/293);
+                wait_ms(250);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/329);
+                wait_ms(150);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/369);
+                wait_ms(250);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/369);
+                wait_ms(100);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/493);
+                wait_ms(350);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                //endintro1
+                //intro1-2
+                speaker = 0.01;
+                speaker.period(1.0/246);
+                wait_ms(150);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/277);
+                wait_ms(150);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/293);
+                wait_ms(250);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/329);
+                wait_ms(250);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/293);
+                wait_ms(150);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/277);
+                wait_ms(200);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/440);
+                wait_ms(200);
+                speaker = 0;
+                wait_ms(nWait);
+                
+                speaker = 0.01;
+                speaker.period(1.0/391);
+                wait_ms(150);
+                speaker = 0;
+                wait_ms(nWait);
+                //endintro1-2
+                //END MEME   
+            }      
+}
--- a/map.cpp	Tue Nov 19 16:53:47 2019 +0000
+++ b/map.cpp	Sun Nov 24 03:22:35 2019 +0000
@@ -223,4 +223,132 @@
     w1->data = NULL;
     void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1);
     if (val) free(val); // If something is already there, free it   
-}
\ No newline at end of file
+}
+
+void add_key(int x, int y){
+    MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+    w1->type = keyItem;
+    w1->draw = draw_key;
+    w1->walkable = true;
+    w1->data = NULL;
+    void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1);
+    if (val) free(val); // If something is already there, free it   
+}
+
+void add_sonar(int x, int y){
+    MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+    w1->type = sonar;
+    w1->draw = draw_sonar;
+    w1->walkable = false;
+    w1->data = NULL;
+    void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1);
+    if (val) free(val); // If something is already there, free it   
+}
+
+void add_treasure(int x, int y){
+    MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+    w1->type = treasure;
+    w1->draw = draw_treasure;
+    w1->walkable = false;
+    w1->data = NULL;
+    void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1);
+    if (val) free(val); // If something is already there, free it   
+}
+
+
+void add_gate(int x, int y){
+    MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+    w1->type = gate;
+    w1->draw = draw_gate;
+    w1->walkable = false;
+    w1->data = NULL;
+    void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1);
+    if (val) free(val); // If something is already there, free it   
+}
+
+void add_prisoner(int x, int y){
+    MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+    w1->type = prisoner;
+    w1->draw = draw_prisoner;
+    w1->walkable = false;
+    w1->data = NULL;
+    void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1);
+    if (val) free(val); // If something is already there, free it   
+}
+
+void add_expPnt(int x, int y){
+    MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+    w1->type = expPnt;
+    w1->draw = draw_expPnt;
+    w1->walkable = true;
+    w1->data = NULL;
+    void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1);
+    if (val) free(val); // If something is already there, free it   
+}
+
+void add_water(int x, int y, int dir, int len)
+{
+    for(int i = 0; i < len; i++)
+    {
+        MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+        w1->type = water;
+        w1->draw = draw_water;
+        w1->walkable = false;
+        w1->data = NULL;
+        unsigned key = (dir == HORIZONTAL) ? XY_KEY(x+i, y) : XY_KEY(x, y+i);
+        void* val = insertItem(get_active_map()->items, key, w1);
+        if (val) free(val); // If something is already there, free it
+    }
+}
+
+void add_rock(int x, int y, int dir, int len)
+{
+    for(int i = 0; i < len; i++)
+    {
+        MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+        w1->type = rock;
+        w1->draw = draw_rock;
+        w1->walkable = false;
+        w1->data = NULL;
+        unsigned key = (dir == HORIZONTAL) ? XY_KEY(x+i, y) : XY_KEY(x, y+i);
+        void* val = insertItem(get_active_map()->items, key, w1);
+        if (val) free(val); // If something is already there, free it
+    }
+}
+
+void add_wood(int x, int y, int dir, int len)
+{
+    for(int i = 0; i < len; i++)
+    {
+        MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+        w1->type = wood;
+        w1->draw = draw_wood;
+        w1->walkable = false;
+        w1->data = NULL;
+        unsigned key = (dir == HORIZONTAL) ? XY_KEY(x+i, y) : XY_KEY(x, y+i);
+        void* val = insertItem(get_active_map()->items, key, w1);
+        if (val) free(val); // If something is already there, free it
+    }
+}
+
+
+void add_waterS1(int x, int y){
+    MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+    w1->type = waterS1;
+    w1->draw = draw_waterS1;
+    w1->walkable = true;
+    w1->data = NULL;
+    void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1);
+    if (val) free(val); // If something is already there, free it   
+}
+
+
+void add_waterS2(int x, int y){
+    MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+    w1->type = waterS2;
+    w1->draw = draw_waterS2;
+    w1->walkable = true;
+    w1->data = NULL;
+    void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1);
+    if (val) free(val); // If something is already there, free it   
+}
--- a/map.h	Tue Nov 19 16:53:47 2019 +0000
+++ b/map.h	Sun Nov 24 03:22:35 2019 +0000
@@ -59,6 +59,17 @@
 //MYCODE
 #define NPC     2
 #define ladder  3
+#define keyItem 4
+#define sonar   5
+#define treasure 6
+#define water   7
+#define rock    8
+#define wood    9
+#define gate    10
+#define prisoner 11
+#define expPnt  12
+#define waterS1 13
+#define waterS2 14
 
 /**
  * Initializes the internal structures for all maps. This does not populate
@@ -158,5 +169,16 @@
 //MYCODE
 void add_NPC(int x, int y);
 void add_ladder(int x, int y);
+void add_key(int x, int y);
+void add_sonar(int x, int y);
+void add_treasure(int x, int y);
+void add_gate(int x, int y);
+void add_prisoner(int x, int y);
+void add_expPnt(int x, int y);
+void add_water(int x, int y, int dir, int len);
+void add_rock(int x, int y, int dir, int len);
+void add_wood(int x, int y, int dir, int len);
+void add_waterS1(int x, int y);
+void add_waterS2(int x, int y);
 
 #endif //MAP_H
\ No newline at end of file
--- a/speech.cpp	Tue Nov 19 16:53:47 2019 +0000
+++ b/speech.cpp	Sun Nov 24 03:22:35 2019 +0000
@@ -59,7 +59,16 @@
             uLCD.locate(1, locateY);
         }   
         uLCD.printf("%c", line[i]);
-        wait_ms(25);
+        
+        //SANS TEST
+        speaker = 0.001;
+        speaker.period(1.0/160);
+        wait_ms(15);
+        speaker = 0;
+        wait_ms(10);
+        //ENDSANS TEST
+        
+        //wait_ms(25);
     }
     
     
@@ -83,7 +92,7 @@
 
 void speech_bubble_wait()
 {
-    wait_ms(2500);
+    wait_ms(1500);
 }
 
 void speech(const char* line1, const char* line2)