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.
lib/Banana/Banana.cpp
- Committer:
- Kern_EL17KJTF
- Date:
- 2019-05-08
- Revision:
- 12:50a7abf21f18
- Parent:
- 11:b288d01533cc
- Child:
- 13:94abfe83a294
File content as of revision 12:50a7abf21f18:
/* ELEC2645 Project Banana.cpp Class file for Banana in Donkey Kong game. */ #include "Banana.h" Banana::Banana() { } Banana::~Banana() { } int banana_x = 0; int banana_y = 0; int banana_speed = 0; int banana_min = 0; int banana_max = 76; int banana_time = 0; int score = 0; 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,}, {0,0,0,0,1,1,1,1,}, {0,0,0,1,1,1,1,0,}, {0,1,1,1,1,1,1,0,}, {1,1,1,1,1,1,0,0,}, {0,1,1,1,0,0,0,0,}, }; 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 > 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); } }