Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Revision:
53:527cf297b088
Parent:
51:387249f9b333
Child:
54:20abd16c7d74
--- a/GameObjects/Blocks/Blocks.cpp	Fri Apr 26 18:44:45 2019 +0000
+++ b/GameObjects/Blocks/Blocks.cpp	Fri Apr 26 19:09:39 2019 +0000
@@ -298,13 +298,18 @@
         round = _length/(2); //to make sure at least two smaller than the snake size (two because one is already smaller)
         caseselect[rand()%5] = floor(round);
         k = k+1; //to stop this if function to keep executing.
-     }
-    lcd.drawSprite(_bx+3,_by,11,1,(int *)Frame); //Function to draw the sprite.
-    lcd.drawSprite(_bx+19,_by,11,1,(int *)Frame);
-    lcd.drawSprite(_bx+35,_by,11,1,(int *)Frame);
-    lcd.drawSprite(_bx+51,_by,11,1,(int *)Frame);
-    lcd.drawSprite(_bx+67,_by,11,1,(int *)Frame);
-    lcd.drawSprite(_bx+83,_by,11,1,(int *)Frame);
+    }
+    Blocks::DrawFrame(lcd);
+    Blocks::ChooseBlocks(lcd);
+}
+
+void Blocks::DrawFrame(N5110 &lcd)  {
+    for(int i = 3; i <= 83; i += 16) {
+        lcd.drawSprite(_bx+i,_by,11,1,(int *)Frame); //Function to draw the frame at all i coordinates as x.
+    }
+}
+
+void Blocks::ChooseBlocks(N5110 &lcd)  {
     i = 0;
     pos = 4; //this refers to the x coordinate of the blocks.
     while((i<5)&&(pos<=68))  {
@@ -366,8 +371,6 @@
     }
 }
 
-
-
 Vector2D Blocks::get_pos() //Obtains the X and Y coordinate of the target.
 {
     Vector2D blockpos = {_bx,_by};
@@ -382,7 +385,7 @@
 
 
 void Blocks::update(int blocknum, int blockgap, int srn, int send_block_number) //send sends the block number only when the y position satisfies a particular requirement
-{                                                                 //and srn gives the srn of the block, snake is colliding with.
+{                                                                               //and srn gives the srn of the block, snake is colliding with.
     // this if function makes sure the block appears at the rate of blockgap.
     if(_by >= (blockgap)){
         k = 0;