Final Commit

Dependencies:   mbed

Revision:
23:3081be418c89
Parent:
21:63c5590cb2c2
Child:
24:4b180348826e
--- a/SnakeEngine/SnakeEngine.h	Tue May 01 09:44:53 2018 +0000
+++ b/SnakeEngine/SnakeEngine.h	Tue May 01 10:55:49 2018 +0000
@@ -47,21 +47,79 @@
     SnakeEngine(); // constructor
     ~SnakeEngine(); // destructor
     
-    void init(Direction in, Direction cur, int pos_x, int pos_y); // initiallises the position of the food, and snake 
-    void draw(N5110 &lcd); // draws snake/food to the lcd
-    void update(Gamepad &pad); // updates depending on gamepad input
-    void get_input(Gamepad &pad); // gets the input from the gamepad
+    
+    /** Initialises the directions for the snake and the position for the food
+    * @param Input direction from pad
+    * @param Current direction of snake
+    * @param pos_x x position
+    * @param pos_y y position   
+    */
+    
+    void init(Direction in, Direction cur, int pos_x, int pos_y); 
+    
+    /** Updates the Food and Snake classes from the Gamepad 
+    */
+    
+    void update(Gamepad &pad);
+    
+    /** Gets the updated direction from the Gamepad and stores it in a struct 
+    */
+    
+    
+    void get_input(Gamepad &pad); 
+    
+    /** Check if snake has eaten food
+    */
     
     bool detect_food_collision(Gamepad &pad);
+    
+    /** Checks if snake has hit wall 
+    */
     bool detect_wall_collision(Gamepad &pad);
+    
+    /** Checks if snake has hit it's own tail
+    */
+    
     bool detect_tail_collision();
     
+    /** Increments the length variable for tail when food is eaten
+    * @param Checks if food and head have collided (been eaten)
+    */
+    
     void set_tail_length(bool collision_detected);
+    
+    /** Gets the updated length
+    * @return returns the length of the tail
+    */
+    
     int get_tail_length();
+
+    /** Creates an updated array of tail segments
+    * @details When the engine_frame counter is odd it sets the odd_array,
+               when the engine counter is even it sets the even_array.                 
+    */
     
+    void set_tail_array(Gamepad &pad);
+    
+    /** Updates the odd array with new positions
+    * @details For the odd array it initially sets index 0 of even array to the 
+               new position, then makes each odd index equal to the even 
+               index -1 starting from the the bottom of the array finally adding
+               the new position to index 0
+    */
+
     void set_odd_array(Gamepad &pad);
+    
+    /** Updates the even array with new positions
+    * @details For the even array it initially sets index 0 of odd array to the 
+               new position, then makes each even index equal to the odd 
+               index -1 starting from the the bottom of the array finally adding
+               the new position to index 0
+    */
+    
     void set_even_array(Gamepad &pad);
-    void set_tail_array(Gamepad &pad);
+    
+    /** Draws the tail segments on the lcd */
     
     void draw_tail(N5110 &lcd);