Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Revision:
83:329da564799a
Parent:
81:4c1641e10dcd
Child:
87:871d9fecb593
--- a/GameObjects/Snake/Snake.cpp	Mon May 06 10:49:50 2019 +0000
+++ b/GameObjects/Snake/Snake.cpp	Mon May 06 14:28:35 2019 +0000
@@ -17,21 +17,28 @@
     {0,1,0},
 };
 
-void Snake::init(int length, int speed)
+void Snake::init(N5110 *lcd)
+{
+    _lcd = lcd;
+    _speed = 1;
+    reset = 0; //Variable used to allow a starting location for the player.
+}
+
+void Snake::_setLength(int length)
 {
     _length = length;
     if(length >= 10) {
         _length = 10;   //to stop the snake length virtually at 10 when it goes past it.
     }
-
-    _speed = speed;// change this according to the options selected
-    reset = 0; //Variable used to allow a starting location for the player.
 }
 
+void Snake::_setSpeed(int speed)
+{
+    _speed = speed;
+}
 
-void Snake::draw(N5110 &lcd, int length)
+void Snake::draw()
 {
-    _length = length;
     if(reset == 0) {
 
         Vector2D p = {WIDTH/2, HEIGHT - 3};  //Spawns player sprite near the middle of the screen.
@@ -42,7 +49,7 @@
     //printf("SPRITE %d %d \n", _x[0], _y[0]);
 
     for(int i=0; i<=_length-1; i++)  {
-        lcd.drawSprite(_x[i],_y[i],3,3,(int *)snake_sprite); //Function used to draw the sprite.
+        _lcd->drawSprite(_x[i],_y[i],3,3,(int *)snake_sprite); //Function used to draw the sprite.
     }
 }