Game For ECE 2035

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Revision:
7:862062ffca62
Parent:
6:c9695079521d
Child:
9:cbb9cfb1f6c5
--- a/map.cpp	Fri Nov 19 22:03:25 2021 +0000
+++ b/map.cpp	Sat Nov 20 03:37:50 2021 +0000
@@ -176,18 +176,18 @@
     }
 }
 
-void add_castle(int x, int y)
+void add_castle(int x, int y, int dir, int len)
 {
-    //for(int i = 0; i < len; i++) {
+    for(int i = 0; i < len; i++) {
         MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
         w1->type = CASTL;
         w1->draw = draw_castle;
         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, XY_KEY(x,y), w1);
+        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
-    
+    }
 }
 
 
@@ -213,6 +213,30 @@
     if (val) free(val);
 }
 
+void add_kindom(int x, int y)
+{
+    MapItem*w1 = (MapItem*) malloc(sizeof(MapItem));
+    w1->type = KINDOM;
+    w1->draw = draw_kindom;
+    w1->walkable = false;
+    w1->data = NULL;
+    void* val = insertItem(get_active_map()->items,XY_KEY(x,y),w1);
+    if (val) free(val);
+}
+
+
+void add_portal2(int x, int y)
+{
+    MapItem*w1 = (MapItem*) malloc(sizeof(MapItem));
+    w1->type = PORTAl;
+    w1->draw = draw_portal2;
+    w1->walkable = true;
+    w1->data = NULL;
+    void* val = insertItem(get_active_map()->items,XY_KEY(x,y),w1);
+    if (val) free(val);
+}
+
+
 void add_chest(int x, int y)
 {
     MapItem*chest = (MapItem*) malloc(sizeof(MapItem));
@@ -224,6 +248,27 @@
     if (val) free(val);
 }
 
+void add_door(int x, int y)
+{
+    MapItem*w1 = (MapItem*) malloc(sizeof(MapItem));
+    w1->type = DOOR;
+    w1->draw = draw_door;
+    w1->walkable = false;
+    w1->data = NULL;
+    void* val = insertItem(get_active_map()->items,XY_KEY(x,y),w1);
+    if (val) free(val);
+}
+
+void add_dragon(int x, int y)
+{
+    MapItem*w1 = (MapItem*) malloc(sizeof(MapItem));
+    w1->type = DRAGON;
+    w1->draw = draw_dragon;
+    w1->walkable = false;
+    w1->data = NULL;
+    void* val = insertItem(get_active_map()->items,XY_KEY(x,y),w1);
+    if (val) free(val);
+}