Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: SnakeFood/SnakeFood.cpp
- Revision:
- 25:e827f1a8fadc
- Parent:
- 18:b391caa5754c
- Child:
- 30:461231877c89
--- a/SnakeFood/SnakeFood.cpp Wed Apr 10 10:59:15 2019 +0000
+++ b/SnakeFood/SnakeFood.cpp Wed Apr 10 14:37:05 2019 +0000
@@ -24,7 +24,7 @@
}
-void SnakeFood::draw(N5110 &lcd)
+void SnakeFood::draw(N5110 &lcd, int blockgap, int blockbuff)
{
//_velocity.x = 1;
@@ -35,24 +35,6 @@
//Remember to seed
-
-
-
- /* int random = rand() % 3;
- if(random == 0){
- _velocity.x = 0;
- }
- if(random == 1){
- _velocity.x = 2;
- }
- if(random == 2){
- _velocity.x = -2;
- }
- if(random == 3){
- _velocity.x = -2;
- }
- */
-
//Resets SnakeFood position if it reaches the bottom of the screen.
//Also prevents SnakeFood from going out of the side of the screen.
if(_fx < 0){
@@ -68,6 +50,9 @@
if(n == 0){
_fx = (rand() % 82); //change the number here so that there is always an unsurity(a little) if the food will come or not(change the limits for this)
_fy = -2;
+ if((blockbuff>=11)&&(blockbuff<=blockgap-11)) { //this makes sure that the snake food appears seperated from the block
+ _fy = -2;
+ }
n = n+1;
}