Class used to run the maze game loop.

Revision:
5:3635319c64b8
Parent:
4:93fd2f3bd0de
--- a/MazeEngine.cpp	Wed May 03 21:13:52 2017 +0000
+++ b/MazeEngine.cpp	Thu May 04 14:02:05 2017 +0000
@@ -1,24 +1,24 @@
-/*
- 
- @file mazeEngine.cpp
- 
- (c) Max Houghton 19.03.2017
- Roller Maze Project, ELEC2645, Univeristy of Leeds
- 
- */
-
 #include "MazeEngine.h"
 
+/**
+ *  @details - constructor
+ */
 MazeEngine::MazeEngine()
 {
     
 }
 
+/**
+ *  @details - constructor
+ */
 MazeEngine::~MazeEngine()
 {
     
 }
 
+/**
+ *  @details - Initialises the game with specified paramters
+ */
 void MazeEngine::init(int mazeIndex,
                       int x,
                       int y,
@@ -46,6 +46,9 @@
     _maze.init(_mazeIndex);
 }
 
+/**
+ *  @details - Reads input from chosen device
+ */
 void MazeEngine::readInput(Gamepad &pad, FXOS8700CQ &device)
 {
     if (_control){  // if control is true (default), input comes from joystick
@@ -56,6 +59,9 @@
     }
 }
 
+/**
+ *  @details - Reads joystick input
+ */
 void MazeEngine::readJoystickInput(Gamepad &pad)
 {
     // position is a 2D struct for (x,y)
@@ -64,6 +70,9 @@
     // printf("Joystick inputs: %.2f, %.2f \n", position.x, position.y);
 }
 
+/**
+ *  @details - Reads accelerometer input
+ */
 void MazeEngine::readAccelerometer(FXOS8700CQ &device)
 {
     // acquire values from device
@@ -77,6 +86,9 @@
     position.y = roll / -60;
 }
 
+/**
+ *  @details - Checks for wall collisions
+ */
 void MazeEngine::checkWallCollision(N5110 &lcd)
 {
     // acquire position of ball
@@ -94,7 +106,7 @@
     int lowerSide = int (_position.y + _radius);
     
     // check position of ball
-    // if distance between outermost pixel and centre changes
+    // if distance between outermost pixel and centre != original distance
     // there must be a pixel in adjacent position
     if (leftSide + _mazeArray[leftSide - 1][int(_position.y)] != leftSide){
         
@@ -131,7 +143,9 @@
     _ball.setVelocity(_velocity);
 }
 
-
+/**
+ *  @details - updates the game
+ */
 void MazeEngine::update(N5110 &lcd)
 {
     // check if ball is in goal before moving to next position
@@ -150,6 +164,9 @@
     
 }
 
+/**
+ *  @details - Acquires maze array used for wall collision checks
+ */
 void MazeEngine::getMazeArray(N5110 &lcd)
 {
     for (int i = 0; i < 84; i++){
@@ -170,6 +187,9 @@
     }
 }
 
+/**
+*   @details - Draws ball and maze
+*/
 void MazeEngine::draw(N5110 &lcd)
 {
     // mazes are drawn according to selected maze index (default = 0)
@@ -180,6 +200,9 @@
     _ball.draw(lcd);
 }
 
+/**
+ *  @details - Checks if goal has been achieved.
+ */
 bool MazeEngine::checkGoal()
 {
     Vector2D position = _ball.getPosition();
@@ -205,6 +228,7 @@
     }
     
     else {
+        
         if (position.x > 86){
             
             // printf("Goal reached");