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: lib/Banana/Banana.cpp
- Revision:
- 32:dca62ba807de
- Parent:
- 17:ac0cb2980f6e
--- a/lib/Banana/Banana.cpp Thu May 09 01:40:45 2019 +0000 +++ b/lib/Banana/Banana.cpp Thu May 09 01:52:56 2019 +0000 @@ -39,7 +39,7 @@ }; // Spawns a banana at a random x location, then slowly falls down screen. When reaches bottom or collected by player it restarts. -void Banana::banana_drop(Gamepad &pad, N5110 &lcd, Barrel &barrel, Donkey &dky) { +void Banana::banana_drop(Gamepad &pad, N5110 &lcd, Barrel &barrel, Donkey &dky, Options &opt) { if (((banana_x + 8) >= barrel_x) & (banana_x <= (barrel_x + 16)) & (banana_y <= 4)) { // Makes sure not in same position as barrel sprite. banana_x = rand() % (banana_max + 1 - banana_min) + banana_min; // Random x spawn coordinate. } @@ -57,10 +57,17 @@ } if ((banana_y >= 34) & ((banana_x + 7) >= donkeykong_x) & (banana_x <= (donkeykong_x + 15))) { // If banana collides with player sprite, then adds to score and resets. score = score + 10 + banana_time; + banana_hit(pad, lcd, barrel, dky, opt); banana_y = 0; banana_x = rand() % (banana_max + 1 - banana_min) + banana_min; //printf("Banana Hit - Score: %d \n", score); // Prints running score to external computer screen. //printf("Banana x %d \n", banana_x); //printf("Barrel x %d \n", barrel_x); } +} + +void Banana::banana_hit(Gamepad &pad, N5110 &lcd, Barrel &barrel, Donkey &dky, Options &opt) { + if (opt_volume == 1) { + pad.tone(2400, 0.2); + } } \ No newline at end of file