Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Revision:
41:4edac50f010d
Parent:
39:210ac915e0a0
Child:
42:973bb6036f81
--- a/SnakevsBlock/SnakevsBlock.h	Mon Apr 22 07:10:52 2019 +0000
+++ b/SnakevsBlock/SnakevsBlock.h	Tue Apr 23 12:25:49 2019 +0000
@@ -6,6 +6,7 @@
 #include "FXOS8700CQ.h"
 #include "Gamepad.h"
 #include "Snake.h"
+#include "LengthCalc.h"
 #include "SnakeFood.h"
 #include "Blocks.h"
 #include "StartScreen.h"
@@ -24,6 +25,12 @@
     */
     void init( );
     
+    /** Reset Game Machine
+    *
+    *   This function prepares the game machine for the next level.
+    */
+    void reset( );
+    
     /** Read Input
     *
     *   This function obtains numeric data from the gamepads joystick.
@@ -34,19 +41,13 @@
     *
     *   This function contains the update functions of the other libraries used in the game.
     */
-    int update(Gamepad &pad, SDFileSystem &sd);
+    int update(Gamepad &pad);
     
     /** Draw 
     *
     *   This function contains the draw functions of the other libraries used in the game.
     */
-    void draw(N5110 &lcd, Gamepad &pad);
-    
-    /** Print Length on the nokia screen
-    *
-    *   This function is called in draw and just signifies the length to be displayed.
-    */
-    void print_length_on_screen(N5110 &lcd);
+    void draw(N5110 &lcd, Gamepad &pad, SDFileSystem &sd);
     
     /** Get Position
     *
@@ -66,12 +67,12 @@
     */
     void ImplementCollision(Gamepad &pad);
     
-    
-    int snakex;
-    int snakey;
+    int snakex; //x position of top beed
+    int snakey; //y position of top beed
     int length;
     int velocity; //this is to stop/move the background (food and blocks), when collision occurs at a length greater than 10.
     int level;
+    char bufferlevel[14];  //this helps me print the level on screen.
     int garbage; //to save the angle at the point button A is pressed.
     float angle; //saves the angle of tilt.
     int foodbuff;  //this makes food 1,2,and 3 come at seperate times
@@ -80,21 +81,24 @@
     int blockbuff; // to manage the fall of food relative to the blocks
     int srn;
     int send; //makes sure that the block number is only updated when send is activated.
-    int speed; //makes sure that snake only moves if not colliding to block walls
     int back; //enables the player to go back on main menu if back is pressed.
     int b[15];
     int b0_to_b14[15];
+    int *b_number; //pointer to save the numbers inside the block.
     Vector2D snake_pos[15];
+    Vector2D food_pos[3];
+    Vector2D b_pos;
     
     private:
-    
     Snake _s;
+    LengthCalc _l;
     SnakeFood _f;
     SnakeFood _ff;
     SnakeFood _fff;
     Blocks _b;
     Stats _statset;
     int _speed;
+    int _length;
     Direction _d;
     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.