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
Diff: Coin/Coin.cpp
- Revision:
- 18:ba4159ab4da7
- Parent:
- 17:ce6b54422113
- Child:
- 19:1073cc64cb0b
diff -r ce6b54422113 -r ba4159ab4da7 Coin/Coin.cpp --- a/Coin/Coin.cpp Wed May 08 13:03:24 2019 +0000 +++ b/Coin/Coin.cpp Wed May 08 15:01:45 2019 +0000 @@ -1,8 +1,6 @@ #include "Coin.h" Coin::Coin(){ - x_coin = 41; - y_coin = 42; _spawn = true; } @@ -32,7 +30,6 @@ } bool Coin::collidePlayer(int x, int y, Gamepad &pad) { - for (int ix = 0; ix < 7; ix++) { for (int iy = 0; iy < 7; iy++) { if ( x + ix == x_coin - 1 && @@ -40,6 +37,21 @@ ++coin; pad.tone(650,0.25); return true; + } else if ( x + ix == x_coin + 2 && + y + iy == y_coin) { + ++coin; + pad.tone(650,0.25); + return true; + } else if ( x + ix == x_coin && + y + iy == y_coin - 1) { + ++coin; + pad.tone(650,0.25); + return true; + } else if ( x + ix == x_coin && + y + iy == y_coin + 2) { + ++coin; + pad.tone(650,0.25); + return true; } } } @@ -49,12 +61,8 @@ void Coin::spawn(int x, int y, N5110 &lcd, Gamepad &pad) { drawSprite(lcd); if (collidePlayer(x,y,pad) == true) { - char buffer[14]; - sprintf(buffer,"%2d",coins()); - printf(buffer,77,40); x_coin = 100; y_coin = 100; - } else { }