project for 2035
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Diff: map.cpp
- Revision:
- 9:c9d6eda597b0
- Parent:
- 8:2e18a96e0c77
- Child:
- 16:ffec120dd665
diff -r 2e18a96e0c77 -r c9d6eda597b0 map.cpp --- a/map.cpp Tue Nov 24 12:35:16 2020 +0000 +++ b/map.cpp Tue Nov 24 22:25:57 2020 +0000 @@ -33,8 +33,7 @@ * This function should uniquely map (x,y) onto the space of unsigned integers. */ static unsigned XY_KEY(int X, int Y) { - //implement pairing function for unique number - return .5(X+Y)(X+Y+1)+Y; + // TODO: Fix me! } /** @@ -44,16 +43,14 @@ */ unsigned map_hash(unsigned key) { - return key%5; + // TODO: Fix me! } void maps_init() -{ +{ + // TODO: Implement! // Initialize hash table - items = createHashTable(map_hash, 5); // Set width & height - w = 500; - h = 500; } Map* get_active_map() @@ -85,49 +82,49 @@ int map_width() { - return get_active_map()->w; + } int map_height() { - return get_active_map()->h; + } int map_area() { - return map_height()*map_width(); + } MapItem* get_current(int x, int y) { - return getItem(get_active_map()->items, XY_KEY(x,y)); + } MapItem* get_north(int x, int y) { - return getItem(get_active_map()->items, XY_KEY(x,y+1)); + } MapItem* get_south(int x, int y) { - return getItem(get_active_map()->items, XY_KEY(x,y-1)); + } MapItem* get_east(int x, int y) { - return getItem(get_active_map()->items, XY_KEY(x+1,y)); + } MapItem* get_west(int x, int y) { - return getItem(get_active_map()->items, XY_KEY(x-1,y)); + } MapItem* get_here(int x, int y) { - return getItem(get_active_map()->items, XY_KEY(x,y)); + } void map_erase(int x, int y) { - deleteItem(get_active_map()->items, XY_KEY(x,y)); + } void add_wall(int x, int y, int dir, int len)