Project Submission (late)

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
el17tc
Date:
Fri May 10 14:52:28 2019 +0000
Parent:
2:43bb635db736
Commit message:
final commit, API is added.; I'm not sure if there is a specific statement of academic integrity wanted but- I declare that this work is 100% my own, I have not plagiarised any work or attempted to fabricate any part of it for extra marks.

Changed in this revision

Drawer/Drawer.cpp Show annotated file Show diff for this revision Revisions of this file
Drawer/Drawer.h Show annotated file Show diff for this revision Revisions of this file
Drawer/GraphicMatrices.h Show annotated file Show diff for this revision Revisions of this file
Maze/Maze.cpp Show annotated file Show diff for this revision Revisions of this file
Maze/Maze.h Show annotated file Show diff for this revision Revisions of this file
Menus/DefeatMenu.h Show annotated file Show diff for this revision Revisions of this file
Menus/MainMenu.h Show annotated file Show diff for this revision Revisions of this file
Menus/MenuGraphics.h Show annotated file Show diff for this revision Revisions of this file
Menus/Menus.h Show annotated file Show diff for this revision Revisions of this file
Menus/OptionsMenu.h Show annotated file Show diff for this revision Revisions of this file
Menus/StartMenu.h Show annotated file Show diff for this revision Revisions of this file
Menus/VictoryMenu.h Show annotated file Show diff for this revision Revisions of this file
Player/Player.cpp Show annotated file Show diff for this revision Revisions of this file
Player/Player.h Show annotated file Show diff for this revision Revisions of this file
Vector2Di/Vector2Di.cpp Show annotated file Show diff for this revision Revisions of this file
Vector2Di/Vector2Di.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 43bb635db736 -r 83e79d31930c Drawer/Drawer.cpp
--- a/Drawer/Drawer.cpp	Fri May 10 10:51:19 2019 +0000
+++ b/Drawer/Drawer.cpp	Fri May 10 14:52:28 2019 +0000
@@ -1,6 +1,8 @@
 #include "Drawer.h"
 #include "GraphicMatrices.h"
 
+// constructor simply assigns the passed pointers to the
+// class' internal fields for storage
 Drawer::Drawer(Player* playerPtr, N5110* screenPtr) {
     player = playerPtr;
     lcd = screenPtr;
@@ -8,18 +10,19 @@
 
 void Drawer::drawBranch1(Vector2Di loc) {
     Vector2Di peekDirection = player->direction;
-    peekDirection.rotateVector(-PI/2);
-    loc.addVector(peekDirection);    
-    //rotate vector left then move forward one
+    peekDirection.rotateVector(-PI/2); // rotate vector left
+    loc.addVector(peekDirection);      // then move forward one
     
     lcd->drawSprite(0,3,42,21,(int *)greenBranchG);
     if (player->checkLocation(loc, 0, 0)) {
+        //if the square in front is open
         lcd->drawSprite(0,9,30,21,(int *)sideSquare1G);    
         loc.addVector(player->direction); // move forward
     }
     else if (player->checkLocation(loc, 0, 2)) {
+        // if the square in front is the exit
         lcd->drawSprite(0,9,30,21,(int *)sideSquare1G);   
-        lcd->drawSprite(0,8,32,21,(int *)exit2);
+        lcd->drawSprite(0,8,32,21,(int *)exit2); // draw the exit graphic for this position
         return;
     }
     else {
diff -r 43bb635db736 -r 83e79d31930c Drawer/Drawer.h
--- a/Drawer/Drawer.h	Fri May 10 10:51:19 2019 +0000
+++ b/Drawer/Drawer.h	Fri May 10 14:52:28 2019 +0000
@@ -3,20 +3,77 @@
 
 #include "Player.h"
 #include "N5110.h"
-
+/** Drawer Class
+ * @brief A class responsible for searching the maze matrix relative to the player's location
+ * @brief and drawing the correct graphics to the LCD accordingly.
+ * @brief can draw cells up to a distance of 4 in front of the player
+ * @brief (not including the cell they are currently standing in).
+ *
+ * @brief Version 1.0
+ * @author Thomas Caine
+ * @date May 2019
+ */
 class Drawer {
     
     public:
+        /** Create a Drawer object capable of printing to the lcd
+         * @param player - pointer to a player object. Player's direction and position is needed
+         * @param screenPtr - pointer to the LCD object. Important for the lcd object to be shared so it's a pointer.
+         */
         Drawer(Player* player, N5110* screenPtr);
+        
+        /** Draw the first branch.
+         *
+         *  This corresponds to the line of 3 cells in front of the player,
+         *  beginning from the cell immediately to their _left_.
+         * @param location - vector representing the cell to begin branch search from
+         */
         void drawBranch1(Vector2Di loc);
+        /** Draw the second branch.
+         *
+         *  This corresponds to the line of 3 cells in front of the player,
+         *  beginning from the cell immediately to their _right_.
+         * @param location - vector representing the cell to begin branch search from
+         */
         void drawBranch2(Vector2Di loc);
+        /** Draw the third branch.
+         *
+         *  This corresponds to the line of 3 cells in front of the player,
+         *  beginning from the cell forward one and left one.
+         * @param location - vector representing the cell to begin branch search from
+         */
         void drawBranch3(Vector2Di loc);
+        /** Draw the fourth branch.
+         *
+         *  This corresponds to the line of 3 cells in front of the player,
+         *  beginning from the cell forward one and right one.
+         * @param location - vector representing the cell to begin branch search from
+         */
         void drawBranch4(Vector2Di loc);
+        /** Draw the fifth branch.
+         *
+         *  This corresponds to the line of 3 cells in front of the player,
+         *  beginning from the cell forward two and left one.
+         * @param location - vector representing the cell to begin branch search from
+         */
         void drawBranch5(Vector2Di loc);
+        /** Draw the fifth branch.
+         *
+         *  This corresponds to the line of 3 cells in front of the player,
+         *  beginning from the cell forward two and right one.
+         */
         void drawBranch6(Vector2Di loc);
+        /** 
+         * @brief Draw the player's current view to the screen buffer.
+         *  
+         * @details drawScreen() will walk the cells in front of the player, checking
+         * @details which cells are empty or solid. When it finds an empty cell either in
+         * @details front, to the left or to the right of the current cell, it will draw graphics
+         * @details and/or call the drawBranch# functions accordingly.
+         */
         void drawScreen();
         
-    
+        // references to the player and lcd objects
         Player* player;
         N5110* lcd;
     
diff -r 43bb635db736 -r 83e79d31930c Drawer/GraphicMatrices.h
--- a/Drawer/GraphicMatrices.h	Fri May 10 10:51:19 2019 +0000
+++ b/Drawer/GraphicMatrices.h	Fri May 10 14:52:28 2019 +0000
@@ -1,3 +1,14 @@
+/*
+This large file full of matracies is where the graphics for drawing in each specific
+location and branch are stored
+
+If you're curious why they are named after colours, it was because each depth of square
+was given a unique colour when I was planning out the matrices in excel, to help me
+distinguish them.
+*/
+
+
+
 int greenSquareG[48][48] = {
     {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
     {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0},
diff -r 43bb635db736 -r 83e79d31930c Maze/Maze.cpp
--- a/Maze/Maze.cpp	Fri May 10 10:51:19 2019 +0000
+++ b/Maze/Maze.cpp	Fri May 10 14:52:28 2019 +0000
@@ -4,10 +4,12 @@
 #include "mbed.h"
 #include "MazeMatrices.h"
 
+// Constructor generates a maze of solid cells
 Maze::Maze() {
     fillMaze(1);
 }
 
+// Fills the maze with a specific value
 void Maze::fillMaze(int val) {
     for (int i = 0; i < 20; i++) {
         for (int j = 0; j < 20; j++) {
@@ -16,6 +18,8 @@
     }
 }
 
+// cycles through each index to copy a maze to the
+// the maze as stored in the Maze object
 void Maze::copyMaze(int maze[20][20]) {
     fillMaze(1);
     for (int i = 0; i < 20; i++) {
@@ -25,6 +29,8 @@
     }
 }
 
+// randomly selects between 3 variants for one of the 3 available sizes
+// there are 9 mazes in total, the size is user specified but which variant is random
 void Maze::selectMaze(int size) {
     printf("selecting maze size\n");
     srand(time(0));
diff -r 43bb635db736 -r 83e79d31930c Maze/Maze.h
--- a/Maze/Maze.h	Fri May 10 10:51:19 2019 +0000
+++ b/Maze/Maze.h	Fri May 10 14:52:28 2019 +0000
@@ -1,12 +1,40 @@
 #ifndef MAZE_H
 #define MAZE_H
 
+/** Maze Class
+ * @brief This class is responsible for selecting, storing and manipulating the current maze.
+ * @brief It also makes it easier to pass the 2D array of the matrix to other classes
+ * @brief that need access to the maze's data, such as Drawer and Player.
+ *
+ * @brief All pre-defined matrices are 20x20 in size, even if their actual size is smaller 
+ * @brief The extra space is padded with 1's, this is to make the function calling significantly
+ * @brief simpler.
+ *
+ * @brief Version 1.0
+ * @author Thomas Caine
+ * @date May 2019
+ */
 class Maze {
 
     public:
+        /** Create a Maze object to manage the maze matrix.
+         */
         Maze();
+        /** Fill the maze matrix with a specific value in every cell
+         * @param val - the value to put in every cell
+         * Used to reset the maze by setting it to all 1's (solid cells)
+         * every time the game restarts.
+         */
         void fillMaze(int val);
+        /** Copies the contents of a maze to the object's version
+         * @param maze - a predefined maze to be copied into the object's matrix field.
+         * @details the mazes passed to this function are all pre-defined in MazeMatrices.h
+         */
         void copyMaze(int maze[20][20]);
+        /** Randomly selects a maze of a specified size
+         * @param size - can be 12, 16 or 20, all mazes are square.
+         * @details this function will randomly select one from 3 pre-defined mazes.
+         */
         void selectMaze(int size);
     
     public:
diff -r 43bb635db736 -r 83e79d31930c Menus/DefeatMenu.h
--- a/Menus/DefeatMenu.h	Fri May 10 10:51:19 2019 +0000
+++ b/Menus/DefeatMenu.h	Fri May 10 14:52:28 2019 +0000
@@ -6,6 +6,9 @@
 /* screen that displays when the player runs out of time in the maze
 reuses the yes and no buttons so VictoryMenu is included */
 
+/** VictoryMenu Class
+ * @brief Derived from Menu. Displayed when the timer expires.
+ */
 class DefeatMenu : public Menu {
     public:
     DefeatMenu(N5110* screenPtr) : Menu(screenPtr) {
@@ -23,6 +26,8 @@
       lcd->printString("Play again?",10,3);
       lcd->printString("Yes      No",10,4);
     }
+    /** Destructor
+    */
     ~DefeatMenu() {
         delete buttons[0];
         delete buttons[1];
diff -r 43bb635db736 -r 83e79d31930c Menus/MainMenu.h
--- a/Menus/MainMenu.h	Fri May 10 10:51:19 2019 +0000
+++ b/Menus/MainMenu.h	Fri May 10 14:52:28 2019 +0000
@@ -5,6 +5,9 @@
 #include "OptionsMenu.h"
 #include "MenuGraphics.h"
 // StartButton takes you to the start menu screen.
+/** StartButton Class
+ * @brief Derived from Button. Takes you to the StartMenu screen where game params are set.
+ */
 class StartButton : public Button {
     public:
     N5110* lcd;
@@ -21,6 +24,9 @@
 };
 
 // OptionsButton takes you to the game's options.
+/** OptionsButton Class
+ * @brief Derived from Button. Takes you to the options menu.
+ */
 class OptionsButton : public Button {
     public:
     N5110* lcd;
@@ -38,6 +44,9 @@
 
 // The MainMenu is the first menu displayed.
 // It has only two buttons because I did not have time for a leaderboard
+/** MainMenu Class
+ * @brief Derived from Menu. MainMenu is the first menu displayed and serves as the start of the program loop.
+ */
 class MainMenu : public Menu {
     public:
     //Button* buttons[2];
@@ -53,6 +62,8 @@
       lcd->printString("Start",10,2);
       lcd->printString("Options",10,3);
     }
+    /** Destructor
+    */
     ~MainMenu() {
         delete buttons[0];
         delete buttons[1];
diff -r 43bb635db736 -r 83e79d31930c Menus/MenuGraphics.h
--- a/Menus/MenuGraphics.h	Fri May 10 10:51:19 2019 +0000
+++ b/Menus/MenuGraphics.h	Fri May 10 14:52:28 2019 +0000
@@ -1,4 +1,6 @@
 // matrices for menu graphics
+// Don't pick on me for my lame title graphic ;-;
+
 int menuGraphic[12][44] = {
   { 1,1,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1 },
   { 1,1,1,0,0,0,0,0,0,1,1,1,0,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1 },
diff -r 43bb635db736 -r 83e79d31930c Menus/Menus.h
--- a/Menus/Menus.h	Fri May 10 10:51:19 2019 +0000
+++ b/Menus/Menus.h	Fri May 10 14:52:28 2019 +0000
@@ -5,22 +5,37 @@
 #include <sstream>
 
 #include "N5110.h"
-//#include "MenuGraphics.h"
 
 /* because these classes are so short and so closely linked, they are declared
 and defined in the same files for convenience and clarity */
 
-// abstract class for Button
+/** Button Class
+ * @brief An abstract class for all button's in the program
+ * @brief The intent was to take advantage of polymorphism in C++ to cut out some large if-else blocks.
+ * @brief There are two functions to overload, run() is always overloaded.
+ * @brief runBack() is only overloaded for buttons attributed to increasing and decreasing variables, 
+ * @brief for example buttons to modify the maze size or contrast/brightness.
+ *
+ * @brief Version 1.0
+ * @author Thomas Caine
+ * @date May 2019
+ */
 class Button {
     public:
     int x;
     int y;
+    /** Button default constructor
+    */
     Button() {
         x = y = 0;
     }
+    /** virtual run function for polymorphism
+    */
     void virtual run() {
         printf("Button\n");
     }
+    /** virtual runBack function for polymorphism
+    */
     void virtual runBack() {
         printf("Back functionality\n");
         // only overridden in functions that can be pressed backwards e.g. sliders
@@ -28,7 +43,18 @@
     }
 };
 
-// abstract class for Menu
+/** Menu Class
+ * @brief An abstract class for all Menus's in the program
+ * @brief Takes advantage of polymorphism. Draw() function is overriden in every inheriting Menu class.
+ * @brief Score is used in the VictoryMenu and DefeatMenu classes.
+ * @details Due to the similarity of Menu classes and their small size, I did not give them all header and source files.
+ * @details Instead, classes are defined when they are declared in the same file and Buttons and Menus are grouped
+ * @details into the same header files based on common functionality.
+ *
+ * @brief Version 1.0
+ * @author Thomas Caine
+ * @date May 2019
+ */
 class Menu {
     public:
     Button* buttons[3];
@@ -36,9 +62,14 @@
     int numOfButtons;
     int buttonIndex;
     N5110* lcd;
+    /** Constructor for the Menu base class.
+     * @param lcd pointer - Passed to every menu object (derived classes super this constructor) so they can print to the lcd
+     */
     Menu(N5110* screenPtr) : lcd(screenPtr) {
         numOfButtons = buttonIndex = 0;
     }
+    /** Virtual draw function, overloaded by Menus to print unique stuff.
+    */
     void virtual draw() {
         printf("This is a menu\n");
     }
diff -r 43bb635db736 -r 83e79d31930c Menus/OptionsMenu.h
--- a/Menus/OptionsMenu.h	Fri May 10 10:51:19 2019 +0000
+++ b/Menus/OptionsMenu.h	Fri May 10 14:52:28 2019 +0000
@@ -5,6 +5,10 @@
 
 // Button class that can modify brightness
 
+/** BrightnessButton Class
+ * @brief Derived from Button. Can incremement or decremement the lcd brightness.
+ * @brief Can only do so in incremements of 5% and can be volatile due to inputs firing twice.
+ */
 class BrightnessButton : public Button {
     public:
     N5110* lcd;
@@ -27,7 +31,10 @@
 };
 
 // Button class that can modify contrast
-
+/** ContrastButton Class
+ * @brief Derived from Button. Can incremement or decremement the lcd contrast.
+ * @brief Can only do so in incremements of 5% and can be volatile due to inputs firing twice.
+ */
 class ContrastButton : public Button {
     public:
     N5110* lcd;
@@ -52,6 +59,9 @@
 // OptionsMenu lets the player modify the brightness and contrast
 // of the lcd screen. can only increment in 5% steps.
 
+/** OptionsMenu Class
+ * @brief Derived from Menu. Displays the options to change brightness and contrast.
+ */
 class OptionsMenu : public Menu {
     public:
     OptionsMenu(N5110* screenPtr) : Menu(screenPtr) {
@@ -72,6 +82,8 @@
       lcd->printString("Contrast:",10,3);
       lcd->printString(ssc.str().c_str(),30,4);
     }
+    /** Destructor
+    */
     ~OptionsMenu() {
         delete buttons[0];
         delete buttons[1];
diff -r 43bb635db736 -r 83e79d31930c Menus/StartMenu.h
--- a/Menus/StartMenu.h	Fri May 10 10:51:19 2019 +0000
+++ b/Menus/StartMenu.h	Fri May 10 14:52:28 2019 +0000
@@ -5,6 +5,11 @@
 
 
 // button which changes the size of the maze
+/** SizeButton Class
+ * @brief Derived from Button. Allows the user to pick the size of Maze they wish to solve.
+ * @brief Mazes can only be 12x12, 16x16 or 20x20.
+ * @brief If enabled, the timer increases in length for larger mazes.
+ */
 class SizeButton : public Button {
     public:
     SizeButton() {
@@ -24,6 +29,11 @@
 };
 
 // button which toggles the timer on or off
+/** TimerButton Class
+ * @brief Derived from Button. Toggles the timer on or off.
+ * @brief If turned off, the timer will count up instead of down and there is no faliure state.
+ * @brief I.e. the program will only end when the maze is finished.
+ */
 class TimerButton : public Button {
     public:
     TimerButton() {
@@ -37,6 +47,9 @@
 };
 
 // button that triggers the main game loop
+/** PlayButton Class
+ * @brief Derived from Buttons. Triggers the main game loop.
+ */
 class PlayButton : public Button {
     public:
     PlayButton() {
@@ -51,6 +64,9 @@
 
 
 // the StartMenu is the menu for game setup and starting the game.
+/** VictoryMenu Class
+ * @brief Derived from Menu. Used to change the game's parameters of maze size and timer on or off.
+ */
 class StartMenu : public Menu {
     public:
     StartMenu(N5110* screenPtr) : Menu(screenPtr) {
@@ -74,6 +90,8 @@
       lcd->printString(someString.c_str(),10,3);
       lcd->printString("Play",10,5);
     }
+    /** Destructor
+    */
     ~StartMenu() {
         delete buttons[0];
         delete buttons[1];
diff -r 43bb635db736 -r 83e79d31930c Menus/VictoryMenu.h
--- a/Menus/VictoryMenu.h	Fri May 10 10:51:19 2019 +0000
+++ b/Menus/VictoryMenu.h	Fri May 10 14:52:28 2019 +0000
@@ -4,6 +4,10 @@
 #include "Menus.h"
 
 // yes button used in the VictoryMenu and the DefeatMenu
+/** YesButton Class
+ * @brief Derived from Button. Used in VictoryMenu and DefeatMenu.
+ * @brief Sends user to the StartMenu.
+ */
 class YesButton : public Button {
     public:
     YesButton() {
@@ -16,6 +20,10 @@
     }
 };
 // no button used in the VictoryMenu and the DefeatMenu
+/** NoButton Class
+ * @brief Derived from Button. Used in VictoryMenu and DefeatMenu.
+ * @brief Sends user to the MainMenu.
+ */
 class NoButton : public Button {
     public:
     NoButton() {
@@ -29,6 +37,10 @@
 };
 // VictoryMenu displays when the player escapes the maze, it displays score
 // and restart options
+/** VictoryMenu Class
+ * @brief Derived from Menu. Displayed when the maze is escaped.
+ * @brief Or more accurately when the winFlag = true.
+ */
 class VictoryMenu : public Menu {
     public:
     VictoryMenu(N5110* screenPtr) : Menu(screenPtr) {
@@ -46,6 +58,8 @@
       lcd->printString("Play again?",10,3);
       lcd->printString("Yes      No",10,4);
     }
+    /** Destructor
+    */
     ~VictoryMenu() {
         delete buttons[0];
         delete buttons[1];
diff -r 43bb635db736 -r 83e79d31930c Player/Player.cpp
--- a/Player/Player.cpp	Fri May 10 10:51:19 2019 +0000
+++ b/Player/Player.cpp	Fri May 10 14:52:28 2019 +0000
@@ -6,10 +6,18 @@
 
 Player::Player(Maze* mazePtr) {
     maze = mazePtr;
-    pos = UP;
-    direction = DOWN;
+    pos = UP; // {0,1} is a temporary value to initialise the variable
+    direction = DOWN; // due to matrices index increasing as you go down
+    // and their acces being [row][column], the standard (x,y) co-ordinate system is
+    // effectively reversed so even though the direction is down, from our perspective
+    // (if we were looking down on the maze) it would be up.
 }
 
+/* Function used to check the value of a cell in the maze from any given cell
+   (not necessarily the player's current position)
+   this function is used a lot in the Drawer (along with other information from the player)
+   so it is important the function is not bound to the player's current location
+*/
 bool Player::checkLocation(Vector2Di origin, double angle, int checkVal) {
     Vector2Di peekDirection = direction;
     peekDirection.rotateVector(angle);
diff -r 43bb635db736 -r 83e79d31930c Player/Player.h
--- a/Player/Player.h	Fri May 10 10:51:19 2019 +0000
+++ b/Player/Player.h	Fri May 10 14:52:28 2019 +0000
@@ -4,14 +4,43 @@
 #include "Maze.h"
 #include "Vector2Di.h"
 
+/** Player Class
+ * @brief This class exists to store information about the player's location in the maze.
+ * @brief more specifically, it stores their coordinates and their direction, both as vectors.
+ * @brief It also facilitates the player's control of the camera via the gamepad.
+ *
+ * @brief Version 1.0
+ * @author Thomas Caine
+ * @date May 2019
+ */
 class Player {
     
     public:
+        /** Create a Player object
+         * @param maze - a maze object so the Player class has access to the maze matrix
+         * @details This constructor does not set the player's position (not to the desired position anyway).
+         * @details The player's proper position is assigned after the Player object's initial creation.
+         */
         Player(Maze* maze);
+        /** Check's the value of the cell in a specified direction from the current cell.
+         * @param origin - vector of the co-ordinates to check from. Not necessarily the Player's current position.
+         * @param angle - double representing the angle to rotate by before checking in front, will always be a multiple of PI/2.
+         * @param checkVal - integer, checkLocation returns true if the checked cell has this value.
+         */
         bool checkLocation(Vector2Di origin, double angle, int checkVal);
+        /** Move the player's position forward one in their current direction.
+         *  Performs validity check first. Won't increment position if cell infront is solid (i.e. 1)
+         */
         void walk();
+        /** Rotates the player's current direction by 90 degrees counter-clockwise.
+         */
         void turnLeft();
+        /** Rotates the player's current direction by 90 degrees clockwise.
+         */
         void turnRight();
+        /** Moves the player one cell backwards.
+         *  Will not work if the cell behind the player is not open.
+         */
         void stepBack();
             
         Vector2Di pos;
diff -r 43bb635db736 -r 83e79d31930c Vector2Di/Vector2Di.cpp
--- a/Vector2Di/Vector2Di.cpp	Fri May 10 10:51:19 2019 +0000
+++ b/Vector2Di/Vector2Di.cpp	Fri May 10 14:52:28 2019 +0000
@@ -1,6 +1,7 @@
 #include "Vector2Di.h"
 
 // Vector manipulation functions
+// they are pretty self explanatory (very basic)
 Vector2Di Vector2Di::operator -() { 
     Vector2Di negV = {x*-1, y*-1};
     return negV;
diff -r 43bb635db736 -r 83e79d31930c Vector2Di/Vector2Di.h
--- a/Vector2Di/Vector2Di.h	Fri May 10 10:51:19 2019 +0000
+++ b/Vector2Di/Vector2Di.h	Fri May 10 14:52:28 2019 +0000
@@ -3,15 +3,35 @@
 
 #include <math.h> 
 #define PI 3.14159265358979323846
-
+/** Vector2Di class
+ * @brief stores a 1x2 vector as _integer_ values.
+ * @brief I am aware one exists already in Gamepad.h that uses floats
+ * @brief but my project only uses vectors as integers and I didn't want to risk
+ * @brief errors or complications arrising from converting back and forth between float and int.
+ *
+ * @brief Version 1.0
+ * @author Thomas Caine
+ * @date May 2019
+ */
 class Vector2Di {
     
     public:
     
         int x;
-        int y;  
+        int y;
+        /** Negation operator overload
+         *  Made the stepBack() function in Player.h easier to implement.
+         *  Simply negates the x and y components of the vector.
+         */
         Vector2Di operator -();
+        /** Adds another vector to this one
+         * @param vector - the Vector2Di object to be added to this vector.
+         */
         void addVector(Vector2Di v);
+        /** Rotate the current vector by a given angle
+         *  @param angle - rotates the vector by a given angle with some simple trig functions
+         *  The angle will always be a multiple of PI/2.
+         */ 
         void rotateVector(double angle);
     
 };
diff -r 43bb635db736 -r 83e79d31930c main.cpp
--- a/main.cpp	Fri May 10 10:51:19 2019 +0000
+++ b/main.cpp	Fri May 10 14:52:28 2019 +0000
@@ -1,3 +1,14 @@
+/*
+ELEC2645 Embedded Systems Project
+School of Electronic & Electrical Engineering
+University of Leeds
+Name: Thomas Caine
+Username: el175c
+Student ID Number: 201127594
+Date: 10/05/2019
+*/
+
+
 #include "mbed.h"
 #include "Gamepad.h"
 #include "N5110.h"
@@ -9,9 +20,20 @@
 #include "DefeatMenu.h"
 #include "VictoryMenu.h"
 
+/* Note:
+If it were up to me almost everything in this file would be in a Game object and main would only have game.init(); game.run(); in it
+Unfortunately I have been plagued by L6312W the empty execution region error (not the warning) all the way through this project
+and this is as good as I could get it in terms of object orientation.
+As far as I'm aware this error is a bug with the mbed compiler of this version but it can be worked around.
+Dock marks as you see fit for not encapsulating the other headers into a single class.
+(but the other classes are nice and object-oriented, right?)
+*/
+
+
 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
 Gamepad gamepad;
-
+/** Causes the currentMenu's button index to be decremented, moving the cursor to the higher button
+*/
 void buttonPressedUp() {
     if (currentMenu->buttonIndex > 0) {
         currentMenu->buttonIndex -= 1;   
@@ -20,6 +42,8 @@
     printf("currentMenu->buttonIndex = %d\n", currentMenu->buttonIndex);
 }
 
+/** Causes the currentMenu's button index to be incremented, moving the cursor to the lower button
+*/
 void buttonPressedDown() {
     if (currentMenu->buttonIndex < (currentMenu->numOfButtons - 1)) {
         currentMenu->buttonIndex += 1;
@@ -33,6 +57,8 @@
 bool arrowFlickFlag = 1;
 int ingameTime;
 
+/** Funciton for drawing the ingame Timer
+ */
 void drawTimer() {
     lcd.drawRect(1,1,20,8,FILL_WHITE);
     std::stringstream ss;
@@ -40,17 +66,27 @@
     std::string timeStr = "Time:" + ss.str();
     lcd.printString(timeStr.c_str(), 1,0);
 }
+/** Timer increment/decrement function
+ * @brief depending on the timerFlag (toggled on or off) it will count up or down
+ */
 void timerFunc() {
     if (timerFlag)
         ingameTime--;
     else
         ingameTime++;
 }
+
+/** Funciton making the button selection arrow flicker
+ * @brief aesthetically pleasing (i think).
+ */
 void selectionArrowFunc() {
     arrowFlickFlag = !arrowFlickFlag;
 };
 
-
+/** The main function
+ * Due to constantly getting Empty Execution region errors this is a lot more full than it should be
+ * refer to note at the top of main.cpp for more comments on the issue.
+ */
 int main() {
     gamepad.init();
     lcd.init();