Game For ECE 2035
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Diff: map.cpp
- Revision:
- 11:6cd02a8539d1
- Parent:
- 10:e18685911e84
- Child:
- 12:116a4cc85b16
--- a/map.cpp Wed Dec 01 22:07:24 2021 +0000 +++ b/map.cpp Thu Dec 02 06:24:22 2021 +0000 @@ -3,8 +3,8 @@ #include "globals.h" #include "graphics.h" -#define NumBuckets 5 -#define NumMaps 2 +#define NumBuckets 10 +#define NumMaps 3 #define HEIGHT 50 #define WIDTH 50 @@ -79,9 +79,9 @@ return &map[active_map]; } -int get_current_map(){ +int get_map(int m){ - return active_map; + return m; } @@ -168,6 +168,13 @@ removeItem(get_active_map()->items,key); } +void map_delete(int x, int y) +{ + unsigned int key = XY_KEY(x,y); + + deleteItem(get_active_map()->items,key); +} + void add_wall(int x, int y, int dir, int len) { for(int i = 0; i < len; i++) { @@ -196,12 +203,21 @@ } } -MapItem*npc = (MapItem*) malloc(sizeof(MapItem)); +void add_fire(int x, int y) +{ + MapItem*w1 = (MapItem*) malloc(sizeof(MapItem)); + w1->type = CASTL; + w1->draw = draw_fire; + w1->walkable = true; + w1->data = NULL; + void* val = insertItem(get_active_map()->items,XY_KEY(x,y),w1); + if (val) free(val); +} void add_npc(int x, int y) { - + MapItem*npc = (MapItem*) malloc(sizeof(MapItem)); npc->type = NPC; npc->draw = draw_npc; npc->walkable = false; @@ -210,11 +226,62 @@ if (val) free(val); } -void delete_npc(int x, int y) +void add_npc2(int x, int y) +{ + MapItem*w1 = (MapItem*) malloc(sizeof(MapItem)); + w1->type = NPCT; + w1->draw = draw_npc2; + w1->walkable = true; + w1->data = NULL; + void* val = insertItem(get_active_map()->items,XY_KEY(x,y),w1); + if (val) free(val); +} + +void add_store(int x, int y) +{ + MapItem*w1 = (MapItem*) malloc(sizeof(MapItem)); + w1->type = CASTL; + w1->draw = draw_store; + w1->walkable = true; + w1->data = NULL; + void* val = insertItem(get_active_map()->items,XY_KEY(x,y),w1); + if (val) free(val); +} + +void add_merch(int x, int y) { - map_erase(x,y); + MapItem*w1 = (MapItem*) malloc(sizeof(MapItem)); + w1->type = VILL; + w1->draw = draw_merch; + w1->walkable = true; + w1->data = NULL; + void* val = insertItem(get_active_map()->items,XY_KEY(x,y),w1); + if (val) free(val); } +void add_eye(int x, int y) +{ + MapItem*w1 = (MapItem*) malloc(sizeof(MapItem)); + w1->type = ENEMY; + w1->draw = draw_eye; + w1->walkable = true; + w1->data = NULL; + void* val = insertItem(get_active_map()->items,XY_KEY(x,y),w1); + if (val) free(val); +} + +void add_goblin(int x, int y) +{ + MapItem*w1 = (MapItem*) malloc(sizeof(MapItem)); + w1->type = ENEMY; + w1->draw = draw_goblin; + w1->walkable = true; + w1->data = NULL; + void* val = insertItem(get_active_map()->items,XY_KEY(x,y),w1); + if (val) free(val); +} + + void add_portal(int x, int y) { MapItem*w1 = (MapItem*) malloc(sizeof(MapItem));