Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
Diff: GameObjects/SnakeFood/SnakeFood.cpp
- Revision:
- 81:4c1641e10dcd
- Parent:
- 77:5c6bd659c32d
- Child:
- 83:329da564799a
--- a/GameObjects/SnakeFood/SnakeFood.cpp Mon May 06 08:00:56 2019 +0000 +++ b/GameObjects/SnakeFood/SnakeFood.cpp Mon May 06 09:05:09 2019 +0000 @@ -19,7 +19,7 @@ void SnakeFood::init() //Delete Int { - n = 0; + reset = 0; } @@ -30,10 +30,10 @@ //add sideways velocity incase I want to make it dodgy. //Resets SnakeFood position if it reaches the bottom of the screen. - if(n == 0) { + if(reset == 0) { _fx = (rand() % 82); //this makes the food pop up at a random, unspecified location in the x axis. _fy = -3; - n = n+1; + reset = reset+1; } lcd.drawSprite(_fx,_fy,3,3,(int *)food_sprite); //Function to draw the food. @@ -43,7 +43,7 @@ Vector2D SnakeFood::get_pos() //Obtains the X and Y coordinate of the target. { Vector2D snakefoodpos = {_fx,_fy}; - //printf("snakefoodpos from food = %f %f \n", snakefoodpos.x, snakefoodpos.y); + //printf("snakefoodpos from food = %f %f \reset", snakefoodpos.x, snakefoodpos.y); return snakefoodpos; } @@ -52,7 +52,7 @@ { //uses draw() to reset snake position after snake has gone past the screen. if(_fy >= 48) { - n = 0; + reset = 0; } _fx += velocity.x; _fy += velocity.y;