Game For ECE 2035
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Diff: map.cpp
- Revision:
- 9:cbb9cfb1f6c5
- Parent:
- 7:862062ffca62
- Child:
- 10:e18685911e84
diff -r fcc333a8f9e1 -r cbb9cfb1f6c5 map.cpp --- a/map.cpp Sat Nov 20 03:57:56 2021 +0000 +++ b/map.cpp Tue Nov 30 00:48:48 2021 +0000 @@ -190,10 +190,12 @@ } } +MapItem*npc = (MapItem*) malloc(sizeof(MapItem)); + void add_npc(int x, int y) { - MapItem*npc = (MapItem*) malloc(sizeof(MapItem)); + npc->type = NPC; npc->draw = draw_npc; npc->walkable = false; @@ -202,6 +204,12 @@ if (val) free(val); } +void delete_npc(int x, int y) +{ + npc->draw = draw_nothing; + deleteItem(get_active_map()->items,XY_KEY(x,y)); + } + void add_portal(int x, int y) { MapItem*w1 = (MapItem*) malloc(sizeof(MapItem)); @@ -279,7 +287,7 @@ w1->type = PLANT; w1->draw = draw_plant; w1->walkable = true; - w1->data = NULL; + w1->data = FRUIT; void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1); if (val) free(val); // If something is already there, free it } \ No newline at end of file