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.
Diff: Map/Map.cpp
- Revision:
- 28:cc7a93ebd7e7
- Parent:
- 26:0dc10374546f
- Child:
- 29:42651f87522b
diff -r 56b8bb5d14f0 -r cc7a93ebd7e7 Map/Map.cpp
--- a/Map/Map.cpp Thu Apr 25 12:36:12 2019 +0000
+++ b/Map/Map.cpp Thu Apr 25 16:26:34 2019 +0000
@@ -1,3 +1,47 @@
-const int map[200][500] {
- {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
- {
\ No newline at end of file
+#include "Map.h"
+
+Map::Map(){
+}
+
+Map::~Map(){
+}
+
+void Map::init(){
+ _coord.x = 100;
+ _coord.y = 100;
+}
+
+void Map::read_input(FXOS8700CQ &accelerometer){
+ Data values = accelerometer.get_values();
+ _map_change.x = -5*values.ay;
+ _map_change.y = -5*values.ax;
+}
+
+void Map::update(){
+ _coord.x += _map_change.x;
+ _coord.y += _map_change.y;
+ if(_coord.x < 0){ _coord.x = 0;} //boundary conditions to stop the
+ if(_coord.y < 0){ _coord.y = 0;} //the programme trying to display
+ if(_coord.x > 416) {_coord.x = 416;} //undefined region outside the
+ if(_coord.y > 152) {_coord.y = 152;} //gamemap array
+}
+
+void Map::draw(N5110 &lcd){
+ bool pixelstate = false;
+ for(int y = _coord.y; y < (48+_coord.y); y++){
+ for(int x = _coord.x; x < (84+_coord.x); x++){
+ if(gamemap[y][x] == 1){ pixelstate = true;}
+ else{ pixelstate = false;}
+ lcd.setPixel((x-_coord.x), (y-_coord.y), pixelstate);
+ }
+ }
+}
+
+Vector2D Map::get_map_display(){
+ Vector2D top_left_coord = _coord;
+ return top_left_coord;
+}
+
+void Map::set_map_display(Vector2D coord){
+ _coord = coord;
+}
\ No newline at end of file