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.
GameEngine Class Reference
GameEngine Class. More...
#include <GameEngine.h>
Public Member Functions | |
| GameEngine () | |
| GameEngine Constructor. | |
| ~GameEngine () | |
| GameEngine Destructor. | |
| void | gameengine_run (Gamepad &pad, N5110 &lcd, Barrel &barrel, Banana &banana, Donkey &dky, Options &opt) |
| Controls the main game. | |
| void | gameengine_score (Gamepad &pad, N5110 &lcd, Banana &banana, HighScores &high) |
| Shows game over screen. | |
Detailed Description
GameEngine Class.
This class is running and contrling the main game functions.
- Version:
- 1.0
- Date:
- May 2019
Definition at line 20 of file GameEngine.h.
Constructor & Destructor Documentation
| GameEngine | ( | ) |
GameEngine Constructor.
Builds my default GameEngine constructor.
This does not have any setup.
Definition at line 10 of file GameEngine.cpp.
| ~GameEngine | ( | ) |
GameEngine Destructor.
Builds my default GameEngine destructor.
This does not have any setup.
Definition at line 16 of file GameEngine.cpp.
Member Function Documentation
| void gameengine_run | ( | Gamepad & | pad, |
| N5110 & | lcd, | ||
| Barrel & | barrel, | ||
| Banana & | banana, | ||
| Donkey & | dky, | ||
| Options & | opt | ||
| ) |
Controls the main game.
- Parameters:
-
pad The Gamepad class is used. lcd The N5110 class is used. barrel The Barrel class is used. banana The Banana class is used. dky The Donkey class is used. opt The Options class is used.
- Returns:
- None.
Runs the main functions of the game in correct order.
void GameEngine::gameengine_run(Gamepad &pad, N5110 &lcd, Barrel &barrel, Banana &banana, Donkey &dky, Options &opt) { wait_ms(250); // Sets key variables back to default value when game first ran. barrel_x = 0; barrel_y = 0; banana_x = 0; banana_y = 0; running = 1; banana_time = 0; barrel_time = 0; score = 0; while (running == 1) { // Main game loop, continues until game over occurs. //printf("Game State"); lcd.clear(); dky.donkeykong_movement(pad, lcd); // Calls Donkey Kong model section of game. barrel.barrel_drop(pad, lcd, dky); // Calls Barrel model section of game. banana.banana_drop(pad, lcd, barrel, dky, opt); // Calls Banana model section of game. //printf("state %d", running); lcd.refresh(); // Reloads screen on every cycle, controlled by fps. Default set to 24. wait_ms(1.0f/24); } }
Definition at line 22 of file GameEngine.cpp.
| void gameengine_score | ( | Gamepad & | pad, |
| N5110 & | lcd, | ||
| Banana & | banana, | ||
| HighScores & | high | ||
| ) |
Shows game over screen.
- Parameters:
-
pad The Gamepad class is used. lcd The N5110 class is used. banana The Banana class is used. high The HighScores class is used.
- Returns:
- None.
Prints the gameover screen. Prints various text, including total player score.
void GameEngine::gameengine_score(Gamepad &pad, N5110 &lcd, Banana &banana, HighScores &high) { lcd.clear(); lcd.printString("Game Over!",14,0); lcd.printString("Score:",0,2); char buffer[14]; // Shows final score on screen. sprintf(buffer,"%i",score); lcd.printString(buffer,40,2); high.highscores_new(pad, lcd, banana); // Checks to see if new high score is obtained. lcd.refresh(); wait(5); }
Definition at line 46 of file GameEngine.cpp.
Generated on Tue Jul 12 2022 18:21:51 by
1.7.2