Adventure game written for ECE2035 at the Georgia Institute of Technology

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Revision:
3:289762133fd6
Parent:
2:0876296d9473
Child:
4:cdc54191ff07
--- a/map.cpp	Tue Apr 17 17:17:20 2018 +0000
+++ b/map.cpp	Wed Apr 18 20:18:51 2018 +0000
@@ -7,10 +7,7 @@
  * The Map structure. This holds a HashTable for all the MapItems, along with
  * values for the width and height of the Map.
  */
-typedef struct{
-    HashTable* items;
-    int w, h;
-}Map;
+
 
 /**
  * Storage area for the maps.
@@ -26,9 +23,8 @@
  * This function should uniquely map (x,y) onto the space of unsigned integers.
  */
 static unsigned XY_KEY(int X, int Y) {
-    // TODO: Fix me!
-    //could just calculate the single array position of the location in the map using the offset formula from P1
-    return (map.w)*Y + X;
+    Map * m = get_active_map();
+    return (m->w)*Y + X;
 }
 
 /**
@@ -42,26 +38,24 @@
     return key%5;
 }
 
-void maps_init()
+void maps_init(int h, int w, int buckets)
 {
-    // TODO: Implement!    
-    // Initialize hash table
-    // Set width & height
-    map.items = createHashTable(map_hash, 5);
-    map.w = 50;
-    map.h = 50;
+    Map * m = get_active_map();
+    m->items = createHashTable(map_hash, buckets);
+    m->w = w;
+    m->h = h;
 }
 
 Map* get_active_map()
 {
-
-    return &maps[active_map];
+    
+    return &(maps[active_map]);
 }
 
 Map* set_active_map(int m)
 {
     active_map = m;
-    return &maps[active_map];
+    return &(maps[active_map]);
 }
 
 void print_map()
@@ -82,18 +76,20 @@
 
 int map_width()
 {
-    get_active_map()
-    return map.w;
+    Map * m = get_active_map();
+    return m->w;
 }
 
 int map_height()
 {
-    return map.h;
+    Map * m = get_active_map();
+    return m->h;
 }
 
 int map_area()
 {
-    return map.h*map.w;
+    Map * m = get_active_map();
+    return (m->h)*(m->w);
 }
 
 MapItem* get_north(int x, int y)