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:
- 12:50a7abf21f18
- Parent:
- 11:b288d01533cc
- Child:
- 13:94abfe83a294
--- a/lib/Banana/Banana.cpp Tue May 07 23:01:46 2019 +0000 +++ b/lib/Banana/Banana.cpp Wed May 08 01:28:25 2019 +0000 @@ -16,7 +16,7 @@ } -int banana_x = 30; +int banana_x = 0; int banana_y = 0; int banana_speed = 0; int banana_min = 0; @@ -25,8 +25,7 @@ int score = 0; -void Banana::banana_drop(Gamepad &pad, N5110 &lcd, Barrel &barrel, Donkey &dky) { - int game_banana[8][8] = { +int game_banana[8][8] = { {0,0,0,0,0,0,1,0,}, {0,0,0,0,0,1,1,1,}, {0,0,0,0,0,1,1,1,}, @@ -36,18 +35,26 @@ {1,1,1,1,1,1,0,0,}, {0,1,1,1,0,0,0,0,}, }; - while (((banana_x + 8) >= barrel_x) & (banana_x <= (barrel_x + 8))) { + +void Banana::banana_drop(Gamepad &pad, N5110 &lcd, Barrel &barrel, Donkey &dky) { + if (((banana_x + 8) >= barrel_x) & (banana_x <= (barrel_x + 16)) & (banana_y <= 4)) { banana_x = rand() % (banana_max + 1 - banana_min) + banana_min; } lcd.drawSprite(banana_x,banana_y,8,8,(int *)game_banana); lcd.refresh(); wait_ms(50); banana_y = banana_y + 1 + banana_time; - if (banana_y > 40) { + if (banana_y > 44) { banana_y = 0; banana_time = banana_time + 0.1; + banana_x = rand() % (banana_max + 1 - banana_min) + banana_min; } if ((banana_y >= 34) & ((banana_x + 7) >= donkeykong_x) & (banana_x <= (donkeykong_x + 15))) { score = score + 10 + banana_time; + banana_y = 0; + banana_x = rand() % (banana_max + 1 - banana_min) + banana_min; + printf("Banana Hit - Score: %d \n", score); + //printf("Banana x %d \n", banana_x); + //printf("Barrel x %d \n", barrel_x); } -} \ No newline at end of file + }