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:
- 11:543c62bed764
- Parent:
- 10:68076e3dcc33
- Child:
- 15:4123abb17291
--- a/snake/snake.cpp Sat Apr 20 15:15:44 2019 +0000
+++ b/snake/snake.cpp Sun Apr 21 10:51:50 2019 +0000
@@ -79,8 +79,7 @@
do{
check = 0;
for (int i = 0; i < length; i++) {
- //if(ball_x == _x[i] && ball_y ==_y[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 + 1 >= _x[i] && ball_x - _size -1 <= _x[i] && ball_y + _size + 1 >= _y[i] && ball_y - _size -1 <= _y[i]){
check = 1;
}
}
@@ -102,11 +101,14 @@
wait(0.05);
pad.leds_off();
}
+ if (_score >= hscore){
+ hscore = _score;
+ }
}
void snake::check_over(N5110 &lcd)
{
- if ( _x[0] >= WIDTH - 2 | _x[0] <= 2 | _y[0] >= HEIGHT - 2 | _y[0] <= 2){
+ if ( _x[0] >= WIDTH - 2 || _x[0] <= 1 || _y[0] >= HEIGHT - 2 || _y[0] <= 1){
over = 1;
}
for (int i = 1; i < _length; i++){