Kern Fowler / Mbed 2 deprecated Donkey_Kong_Game

Dependencies:   mbed

Committer:
Kern_EL17KJTF
Date:
Thu May 09 10:46:03 2019 +0000
Revision:
33:3894a7f846a0
Parent:
12:50a7abf21f18
Child:
34:8dbf401b9906
Mbed update at revision 20 caused an issue when running on board. Downgraded the mbed and now works.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kern_EL17KJTF 10:28575a6eaa13 1 #ifndef GAMEENGINE_H
Kern_EL17KJTF 10:28575a6eaa13 2 #define GAMEENGINE_H
Kern_EL17KJTF 10:28575a6eaa13 3
Kern_EL17KJTF 10:28575a6eaa13 4 #include "mbed.h"
Kern_EL17KJTF 10:28575a6eaa13 5 #include "N5110.h"
Kern_EL17KJTF 10:28575a6eaa13 6 #include "Gamepad.h"
Kern_EL17KJTF 12:50a7abf21f18 7 #include "Donkey.h"
Kern_EL17KJTF 10:28575a6eaa13 8 #include "Barrel.h"
Kern_EL17KJTF 10:28575a6eaa13 9 #include "Banana.h"
Kern_EL17KJTF 33:3894a7f846a0 10 #include "HighScores.h"
Kern_EL17KJTF 33:3894a7f846a0 11 #include "Options.h"
Kern_EL17KJTF 12:50a7abf21f18 12
Kern_EL17KJTF 33:3894a7f846a0 13 /** GameEngine Class
Kern_EL17KJTF 33:3894a7f846a0 14 *@brief This class is running and contrling the main game functions.
Kern_EL17KJTF 33:3894a7f846a0 15 *@author Kern Fowler
Kern_EL17KJTF 33:3894a7f846a0 16 *@version 1.0
Kern_EL17KJTF 33:3894a7f846a0 17 *@date May 2019
Kern_EL17KJTF 33:3894a7f846a0 18 */
Kern_EL17KJTF 10:28575a6eaa13 19
Kern_EL17KJTF 33:3894a7f846a0 20 class GameEngine {
Kern_EL17KJTF 10:28575a6eaa13 21
Kern_EL17KJTF 33:3894a7f846a0 22 public:
Kern_EL17KJTF 33:3894a7f846a0 23 /** GameEngine Constructor
Kern_EL17KJTF 33:3894a7f846a0 24 @brief Builds my default GameEngine constructor.
Kern_EL17KJTF 33:3894a7f846a0 25 @details This does not have any setup.
Kern_EL17KJTF 33:3894a7f846a0 26 */
Kern_EL17KJTF 33:3894a7f846a0 27 GameEngine();
Kern_EL17KJTF 33:3894a7f846a0 28 /** GameEngine Destructor
Kern_EL17KJTF 33:3894a7f846a0 29 @brief Builds my default GameEngine destructor.
Kern_EL17KJTF 33:3894a7f846a0 30 @details This does not have any setup.
Kern_EL17KJTF 33:3894a7f846a0 31 */
Kern_EL17KJTF 33:3894a7f846a0 32 ~GameEngine();
Kern_EL17KJTF 33:3894a7f846a0 33 // Mutators
Kern_EL17KJTF 10:28575a6eaa13 34
Kern_EL17KJTF 33:3894a7f846a0 35 /**
Kern_EL17KJTF 33:3894a7f846a0 36 *@brief Controls the main game.
Kern_EL17KJTF 33:3894a7f846a0 37 *@param pad The Gamepad class is used.
Kern_EL17KJTF 33:3894a7f846a0 38 *@param lcd The N5110 class is used.
Kern_EL17KJTF 33:3894a7f846a0 39 *@param barrel The Barrel class is used.
Kern_EL17KJTF 33:3894a7f846a0 40 *@param banana The Banana class is used.
Kern_EL17KJTF 33:3894a7f846a0 41 *@param dky The Donkey class is used.
Kern_EL17KJTF 33:3894a7f846a0 42 *@param opt The Options class is used.
Kern_EL17KJTF 33:3894a7f846a0 43 *@details Runs the main functions of the game in correct order.
Kern_EL17KJTF 33:3894a7f846a0 44 *@code
Kern_EL17KJTF 33:3894a7f846a0 45 void GameEngine::gameengine_run(Gamepad &pad, N5110 &lcd, Barrel &barrel, Banana &banana, Donkey &dky, Options &opt) {
Kern_EL17KJTF 33:3894a7f846a0 46 wait_ms(250);
Kern_EL17KJTF 33:3894a7f846a0 47 // Sets key variables back to default value when game first ran.
Kern_EL17KJTF 33:3894a7f846a0 48 barrel_x = 0;
Kern_EL17KJTF 33:3894a7f846a0 49 barrel_y = 0;
Kern_EL17KJTF 33:3894a7f846a0 50 banana_x = 0;
Kern_EL17KJTF 33:3894a7f846a0 51 banana_y = 0;
Kern_EL17KJTF 33:3894a7f846a0 52 running = 1;
Kern_EL17KJTF 33:3894a7f846a0 53 banana_time = 0;
Kern_EL17KJTF 33:3894a7f846a0 54 barrel_time = 0;
Kern_EL17KJTF 33:3894a7f846a0 55 score = 0;
Kern_EL17KJTF 33:3894a7f846a0 56 while (running == 1) { // Main game loop, continues until game over occurs.
Kern_EL17KJTF 33:3894a7f846a0 57 //printf("Game State");
Kern_EL17KJTF 33:3894a7f846a0 58 lcd.clear();
Kern_EL17KJTF 33:3894a7f846a0 59 dky.donkeykong_movement(pad, lcd); // Calls Donkey Kong model section of game.
Kern_EL17KJTF 33:3894a7f846a0 60 barrel.barrel_drop(pad, lcd, dky); // Calls Barrel model section of game.
Kern_EL17KJTF 33:3894a7f846a0 61 banana.banana_drop(pad, lcd, barrel, dky, opt); // Calls Banana model section of game.
Kern_EL17KJTF 33:3894a7f846a0 62 //printf("state %d", running);
Kern_EL17KJTF 33:3894a7f846a0 63 lcd.refresh(); // Reloads screen on every cycle, controlled by fps. Default set to 24.
Kern_EL17KJTF 33:3894a7f846a0 64 wait_ms(1.0f/24);
Kern_EL17KJTF 33:3894a7f846a0 65 }
Kern_EL17KJTF 33:3894a7f846a0 66 }
Kern_EL17KJTF 33:3894a7f846a0 67 @endcode
Kern_EL17KJTF 33:3894a7f846a0 68 */
Kern_EL17KJTF 33:3894a7f846a0 69 void gameengine_run(Gamepad &pad, N5110 &lcd, Barrel &barrel, Banana &banana, Donkey &dky, Options &opt);
Kern_EL17KJTF 33:3894a7f846a0 70 /**
Kern_EL17KJTF 33:3894a7f846a0 71 *@brief Shows game over screen.
Kern_EL17KJTF 33:3894a7f846a0 72 *@param pad The Gamepad class is used.
Kern_EL17KJTF 33:3894a7f846a0 73 *@param lcd The N5110 class is used.
Kern_EL17KJTF 33:3894a7f846a0 74 *@param banana The Banana class is used.
Kern_EL17KJTF 33:3894a7f846a0 75 *@param high The HighScores class is used.
Kern_EL17KJTF 33:3894a7f846a0 76 *@details Prints the gameover screen. Prints various text, including total player score.
Kern_EL17KJTF 33:3894a7f846a0 77 *@code
Kern_EL17KJTF 33:3894a7f846a0 78 void GameEngine::gameengine_score(Gamepad &pad, N5110 &lcd, Banana &banana, HighScores &high) {
Kern_EL17KJTF 33:3894a7f846a0 79 lcd.clear();
Kern_EL17KJTF 33:3894a7f846a0 80 lcd.printString("Game Over!",14,0);
Kern_EL17KJTF 33:3894a7f846a0 81 lcd.printString("Score:",0,2);
Kern_EL17KJTF 33:3894a7f846a0 82 char buffer[14]; // Shows final score on screen.
Kern_EL17KJTF 33:3894a7f846a0 83 sprintf(buffer,"%i",score);
Kern_EL17KJTF 33:3894a7f846a0 84 lcd.printString(buffer,40,2);
Kern_EL17KJTF 33:3894a7f846a0 85 high.highscores_new(pad, lcd, banana); // Checks to see if new high score is obtained.
Kern_EL17KJTF 33:3894a7f846a0 86 lcd.refresh();
Kern_EL17KJTF 33:3894a7f846a0 87 wait(5);
Kern_EL17KJTF 33:3894a7f846a0 88 }
Kern_EL17KJTF 33:3894a7f846a0 89 @endcode
Kern_EL17KJTF 33:3894a7f846a0 90 */
Kern_EL17KJTF 33:3894a7f846a0 91 void gameengine_score(Gamepad &pad, N5110 &lcd, Banana &banana, HighScores &high);
Kern_EL17KJTF 10:28575a6eaa13 92 };
Kern_EL17KJTF 10:28575a6eaa13 93
Kern_EL17KJTF 10:28575a6eaa13 94 #endif