Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Revision:
64:540aa1602372
Parent:
63:205f0ca48473
Child:
65:2872ca289b49
diff -r 205f0ca48473 -r 540aa1602372 GameEngine/SnakevsBlock/SnakevsBlock.h
--- a/GameEngine/SnakevsBlock/SnakevsBlock.h	Wed May 01 22:35:40 2019 +0000
+++ b/GameEngine/SnakevsBlock/SnakevsBlock.h	Thu May 02 11:30:04 2019 +0000
@@ -43,13 +43,13 @@
     *   This function obtains numeric data from the gamepads joystick.
     */
     void read_input(Gamepad &pad, FXOS8700CQ &device, int gm);
-    
+
     /** Calculate Tilt
     *
     *   This function reads the angle of tilt required for motion contol and also processes it by reseting the angle buffer if A is pressed.
     */
     void calculateTilt(Gamepad &pad, FXOS8700CQ &device);
-    
+
     /** Light The LEDS
     *
     *   This function ligths the LEDS dependent on the direction of travel.
@@ -67,7 +67,7 @@
     *   This function contains the update functions of the other libraries used in the game.
     */
     void update(N5110 &lcd, Gamepad &pad);
-    
+
     /** Check Game Progression
     *
     *   Function handles level progression and level failure operations by using the class WinLoose.
@@ -92,44 +92,9 @@
     */
     void ImplementCollision(Gamepad &pad);
 
-    int snakex; //x position of top beed
-    int snakey; //y position of top beed
-    int length; //saves the length of the snake, for collision detection relative to it's length and calculations.
-    int velocity; //this is to stop/move the background (food and blocks), when collision occurs at a length greater than 10.
-    int level; // this is diffrent to int _length as this stops at 10 to not complicate collisions as the snake doesn't grow longer than 10 visually.
-    char bufferlevel[14];  //this helps me print the level on screen.
-    int garbage; //to save the angle at the point button A is pressed.
-    int foodbuff;  //this makes food 1,2,and 3 come at seperate times
-    int blocknum; // saves the number inside the colliding block, for calculations.
-    int blockgap; //to change frequency of fall
-    int srn; //sr number of the block we are colliding with (1 to 5)
-    int send_block_number; //makes sure that the block number is only updated when send is activated.
-    int back; //enables the player to go back on main menu if back is pressed.
-    int b[15]; //this saves the beed number of the colliding snake, if beed 3 from top was colliding with any obstruction, b[2] will be 1.
-    int *b_number; //pointer to save the numbers inside the block.
-    Vector2D snake_pos[15]; //saves the position of all the snake beeds in an array for ease of collision processing.
-    Vector2D food_pos[3]; //saves the position of all 3 snake food on the screen in a single array for ease of collision processing.
-    Vector2D b_pos; //saves the origin of the blocks on the screen (this is the top left corner of the block row).
-
     //Gamepad @enginePad
 
 private:
-    Snake _s;
-    LengthCalc _l;
-    WinLoose _wl;
-    SnakeFood _f;
-    SnakeFood _ff;
-    SnakeFood _fff;
-    Blocks _b;
-    Stats _Setstats;
-    int _speed;
-    int _length; //this is diffrent to the int length as this saves the length of the snake, for collision detection relative to it's length and calculations.
-    int _maxLength; // this makes us go to the next level if if maxLength is achieved;
-    Direction _d;
-    float _tiltAngle; //saves the angle of tilt.
-    float _mag;
-    int _detect_slowly; //this makes sure that when the length is more than 10, the colliding block doesnt decrease the all the length in a single itteration.
-    int n;
 
     /** Check for Snake and Food collision
     *
@@ -179,10 +144,61 @@
     */
     void checkCollision_EastorWest(int b_x_combination, int i);
 
+    /** Make Virtual Length Max Ten
+    *
+    *  This makes the virtual length -> 10 for the side collision implementation because if the length is fifteen and the last beed collides, it still is the 10th beed
+    *  on screen.
+    */
+    void makeVirtualLengthMaxTen();
+
     /** Stop X Axis Motion
     *
     *   This function implements the sides collision by making the x axis speed of the particular snake beed 0.
     */
-    void StopX_AxisMotion(int length, int i);
+    void StopX_AxisMotion(int i);
+
+    //OBJECT DECLARATIONS.
+    Snake _s;
+    LengthCalc _l;
+    WinLoose _wl;
+    SnakeFood _f;
+    SnakeFood _ff;
+    SnakeFood _fff;
+    Blocks _b;
+    Stats _Setstats;
+
+    //OBJECT POSITIONS ON SCREEN.
+    int snakex; //x position of top beed
+    int snakey; //y position of top beed
+    Vector2D snake_pos[15]; //saves the position of all the snake beeds in an array for ease of collision processing.
+    Vector2D food_pos[3]; //saves the position of all 3 snake food on the screen in a single array for ease of collision processing.
+    Vector2D b_pos; //saves the origin of the blocks on the screen (this is the top left corner of the block row).
+
+    //LEVEL PROGRESSION, FAILURE AND STATISTICS PARAMETERS.
+    int level; // this is diffrent to int _length as this stops at 10 to not complicate collisions as the snake doesn't grow longer than 10 visually.
+    char bufferlevel[14];  //this helps me print the level on screen.
+    int back; //enables the player to go back on main menu if back is pressed.
+    int _maxLength; // this makes us go to the next level if if maxLength is achieved;
+
+    //SNAKE X AXIS VELOCITY, SNAKE LENGTH ,MAX VIRTUAL LENGTH AND VARABLE THAT ALLOWS FREE MOTION OF A SPECIFIC BEED NUMBER OF THE SNAKE.
+    int velocity; //this is to stop/move the background (food and blocks), when collision occurs at a length greater than 10.
+    int _length; //this is diffrent to the _virtualLength as this saves the length of the snake, for collision detection relative to it's length and calculations.
+    int _virtualLength; //saves the length of the snake, for collision detection relative to it's Max screen length.
+    int b[15]; //this saves the beed number of the colliding snake, if beed 3 from top was colliding with any obstruction, b[2] will be 1.
+
+    //TURN DIRECTION, TILT ANGLE AND ANGLE RESET BUFFER (GARBAGE).
+    Direction _d;
+    float _tiltAngle; //saves the angle of tilt.
+    int garbage; //to save the angle at the point button A is pressed.
+
+    //BLOCK NUMBERS, BLOCK DROP GAP, BLOCK DETECTION SRN AND VARIABLE TO SEND/NOT BLOCK NUMBER TO BLOCK CLASS
+    int *b_number; //pointer to save the numbers inside the block.
+    int blocknum; // saves the number inside the specific colliding block, for calculations.
+    int blockgap; //to change frequency of fall
+    int srn; //sr number of the block we are colliding with (1 to 5)
+    int send_block_number; //makes sure that the block number is only updated when send is activated.
+
+    //INITIAL FOOD AND BLOCK DROP GAP.
+    int _dropbuff;  //this makes food 1,2,and 3 come at seperate times
 };
 #endif
\ No newline at end of file