James Cummins / Mbed 2 deprecated el17jnc

Dependencies:   mbed

Revision:
38:a85bc227b907
Parent:
37:de1f584bce71
Child:
40:a1cdb6ab08af
--- a/Map/Map.h	Mon May 06 21:44:49 2019 +0000
+++ b/Map/Map.h	Thu May 09 01:09:18 2019 +0000
@@ -7,6 +7,60 @@
 #include "Gamepad.h"
 #include "Ball.h"
 
+/** Map Class
+@brief Library for interacting with the Classic game mode Map
+
+@author James Cummins
+
+@code
+
+#include "mbed.h"
+#include "Map.h"
+
+//Create a map object
+Map map;
+Ball ball;
+Gamepad gamepad;
+FXOS8700CQ accelerometer(I2C_SDA, I2C_SCL);
+N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
+
+int main(){
+    //Initialise the map first
+    map.init();
+    
+    //Use check wall collision to decide whether to continue game or not
+    while(!(map.check_wall_collision())){
+        
+    //read input and update methods check the user input and update
+    //the map region to be displayed accordingly
+        map.read_input(accelerometer, ball);
+        map.update();
+        
+    //get and set map display can be used to check the intended region of the
+    //map to print and correct it if it's out of bounds
+        Vector2D map_region = map.get_map_display();
+        if(map_region.x > 500){
+            map_region.x = 500;
+            map.set_map_display(map_region);
+        }
+        
+    //combine clear, draw and refresh to update LCD screen each frame
+        lcd.clear();
+        map.draw(lcd);
+        lcd.refresh();
+        
+    //Use get coordinate to check if an object (e.g. ball) is centred 
+    //on a shaded part of the game map
+        Vector2D coord = ball.get_position();
+        int pixel = map.get_coordinate(coord);
+        if(pixel == 1){ break; }
+    }
+}
+
+@endcode
+
+*/
+
 class Map {
 
 public:
@@ -62,6 +116,7 @@
     * @returns
     *       true - coordinate contains a '1'
     *       false - coordinate contains a '0'
+    * @details Method included for testing purposes rather than use in game code
     */
     bool get_coordinate(Vector2D coord);