project for 2035
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Diff: map.cpp
- Revision:
- 7:1912b4a2e4fe
- Parent:
- 6:492048165bba
- Child:
- 8:2e18a96e0c77
--- a/map.cpp Tue Nov 24 11:10:42 2020 +0000 +++ b/map.cpp Tue Nov 24 11:21:33 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)