Still won't work
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Diff: map.cpp
- Revision:
- 3:44a69b76507d
- Parent:
- 0:35660d7952f7
- Child:
- 4:237c791cc5c0
--- a/map.cpp Thu Apr 11 21:09:06 2019 +0000 +++ b/map.cpp Thu Apr 11 23:48:14 2019 +0000 @@ -27,6 +27,7 @@ */ static unsigned XY_KEY(int X, int Y) { // TODO: Fix me! + return X + (Y*map_height()); } /** @@ -37,6 +38,7 @@ unsigned map_hash(unsigned key) { // TODO: Fix me! + return key%50; } void maps_init() @@ -44,6 +46,10 @@ // TODO: Implement! // Initialize hash table // Set width & height + HashTable* ht = createHashTable(&map_hash, 50); + map.items = ht; + map.w = 50; + map.h = 50; } Map* get_active_map() @@ -76,34 +82,46 @@ int map_width() { + return 50; } int map_height() { + return 50; } int map_area() { + return 2500; } MapItem* get_north(int x, int y) { + unsigned ynew = y-1; + return (MapItem*)getItem(map.items,XY_KEY(x,ynew)); } MapItem* get_south(int x, int y) { + unsigned ynew = y+1; + return (MapItem*)getItem(map.items,XY_KEY(x,ynew)); } MapItem* get_east(int x, int y) { + unsigned xnew = x+1; + return (MapItem*)getItem(map.items,XY_KEY(xnew,y)); } MapItem* get_west(int x, int y) { + unsigned xnew = x-1; + return (MapItem*)getItem(map.items,XY_KEY(xnew,y)); } MapItem* get_here(int x, int y) { + return (MapItem*)getItem(map.items,XY_KEY(x,y)); }