Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Diff: map.cpp
- Revision:
- 4:697e1120f821
- Parent:
- 3:bb6f73642f01
- Child:
- 5:5953ca12205d
--- a/map.cpp Mon Nov 16 20:38:03 2020 +0000
+++ b/map.cpp Tue Nov 17 19:14:48 2020 +0000
@@ -23,9 +23,9 @@
#define MAPS_HEIGHT 50
static Map maps[NUM_MAPS];
static int active_map;
-unsigned int NUMBUCKETS = 10000;
+unsigned int NUMBUCKETS = 100;
-
+// this is important
static const MapItem CLEAR_SENTINEL = {
.type = CLEAR,
.draw = draw_nothing
@@ -357,3 +357,48 @@
void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1);
if (val) free(val); // If something is already there, free it
}
+
+void add_arrow_up(int x, int y)
+{
+ MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+ w1->type = ARROWUP;
+ w1->draw = draw_arrow_up;
+ w1->walkable = true;
+ w1->data = NULL;
+ void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1);
+ if (val) free(val); // If something is already there, free it
+}
+
+void add_arrow_down(int x, int y)
+{
+ MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+ w1->type = ARROWDOWN;
+ w1->draw = draw_arrow_down;
+ w1->walkable = true;
+ w1->data = NULL;
+ void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1);
+ if (val) free(val); // If something is already there, free it
+}
+
+void add_arrow_right(int x, int y)
+{
+ MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+ w1->type = ARROWRIGHT;
+ w1->draw = draw_arrow_right;
+ w1->walkable = true;
+ w1->data = NULL;
+ void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1);
+ if (val) free(val); // If something is already there, free it
+}
+
+void add_arrow_left(int x, int y)
+{
+ MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+ w1->type = ARROWLEFT;
+ w1->draw = draw_arrow_left;
+ w1->walkable = true;
+ w1->data = NULL;
+ void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1);
+ if (val) free(val); // If something is already there, free it
+}
+