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.
Dependencies: mbed Gamepad N5110
Diff: snake/snake.cpp
- Revision:
- 9:18b059e5abb9
- Parent:
- 7:d61290faf602
- Child:
- 10:68076e3dcc33
--- a/snake/snake.cpp Tue Apr 16 09:24:49 2019 +0000
+++ b/snake/snake.cpp Sat Apr 20 08:15:10 2019 +0000
@@ -76,7 +76,7 @@
ball_x = 3 + rand() % (WIDTH - 6); // randomise initial position of ball.
ball_y = 3 + rand() % (HEIGHT - 6);
for (int i = 0; i < length; i++) {
- if(ball_x + _size > _x[i] && ball_x - _size < _x[i] && ball_y + _size > _y[i] && ball_y - _size < _y[i]){
+ if(ball_x + _size >= _x[i] && ball_x - _size <= _x[i] && ball_y + _size >= _y[i] && ball_y - _size <= _y[i]){
srand(time(NULL));
ball_x = 3 + rand() % (WIDTH - 6); // randomise initial position of ball.
ball_y = 3 + rand() % (HEIGHT - 6);