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.
Barrel Class Reference
#include <Barrel.h>
Public Member Functions | |
| Barrel () | |
| Barrel Constructor. | |
| ~Barrel () | |
| Barrel Destructor. | |
| void | barrel_drop (Gamepad &pad, N5110 &lcd, Donkey &dky) |
| Spawns the barrel. | |
Detailed Description
Barrel Class.
This class is for spawning the barrel, it will float down the screen. Collision with the player will cause gameover.
- Version:
- 1.0
- Date:
- May 2019
Definition at line 25 of file Barrel.h.
Constructor & Destructor Documentation
| Barrel | ( | ) |
Barrel Constructor.
Builds my default Barrel contructor.
This does not have any setup.
Definition at line 10 of file Barrel.cpp.
| ~Barrel | ( | ) |
Barrel Destructor.
Builds my default Barrel dentructor.
This does not have any setup.
Definition at line 16 of file Barrel.cpp.
Member Function Documentation
Spawns the barrel.
- Returns:
- None.
Spawns a barrel at a random x location, then slowly falls down screen. When reaches bottom it restarts. If collision with player leads to gameover.
void Barrel::barrel_drop(Gamepad &pad, N5110 &lcd, Donkey &dky) { lcd.drawSprite(barrel_x,barrel_y,4,8,(int *)game_barrel); // Draws the barrel sprite on screen with correct coordinates. lcd.refresh(); wait_ms(50); barrel_y = barrel_y + 1 + barrel_time; if (barrel_y > 44) { // If barrel reaches bottom of the screen, the resets. barrel_y = 0; barrel_x = rand() % (barrel_max + 1 - barrel_min) + barrel_min; barrel_time = barrel_time + 0.1; // Moves barrel slowly down screen. } if ((barrel_y >= 34) & ((barrel_x + 7) >= donkeykong_x) & (barrel_x <= (donkeykong_x + 15))) { // If barrel collides with player then sets running to 0, causing gameover. running = 0; //printf("Barrel Hit") } }
Definition at line 38 of file Barrel.cpp.
Generated on Tue Jul 12 2022 18:21:51 by
1.7.2