Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Revision:
59:c65a2e933c47
Parent:
58:affb42c56cf8
Child:
60:d3a9e0e4a0de
--- a/GameEngine/SnakevsBlock/SnakevsBlock.cpp	Sun Apr 28 19:40:50 2019 +0000
+++ b/GameEngine/SnakevsBlock/SnakevsBlock.cpp	Mon Apr 29 12:09:31 2019 +0000
@@ -14,10 +14,11 @@
 {
     //The level initialisation and all the other initial information passing will be done here
     level = 1;
+    _maxLength = 10; // this makes us go to the next level if if maxLength is achieved;
     garbage = 0; //this is to allow the user to change the position of reference for motion control by saving the absolute angle.
     foodbuff = 0; //this makes the food fall at diffrent times when a particular level starts.
     send_block_number = 0; //this is 0 when there is no collision, thus block number isn't remembered for next set (which would lead to empty blocks).
-    blockgap = 350; //this is the number of itterations the block will reccur after in the first level.
+    blockgap = 300; //this is the number of itterations the block will reccur after in the first level.
     for(int i=0; i<=14; i++)  {b[i] = 1;} //makes all the snake beads move by default.
     SnakevsBlock::object_initialisations();
 }
@@ -26,7 +27,7 @@
 {
     //This prepares the game for the next level by reseting certain variables.
     foodbuff = 0;
-    if(blockgap >= 50) {blockgap -= 30;}  //to make progressive levels harder by making the blocks drop more frequently.
+    if(blockgap >= 50) {blockgap -= 10;}  //to make progressive levels harder by making the blocks drop more frequently.
     SnakevsBlock::object_initialisations();
 }
 
@@ -119,7 +120,8 @@
         back = 0;
     }
     //printf("%d\n",_length);
-    if(_length >= 20)  {
+    if(_length >= _maxLength)  {
+        _maxLength++;
         level = _wl.LevelComplete(lcd, pad, level);
         _Setstats.write(level, sd);
         SnakevsBlock::reset();