Kern Fowler / Mbed 2 deprecated Donkey_Kong_Game

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GameEngine.h Source File

GameEngine.h

00001 #ifndef GAMEENGINE_H
00002 #define GAMEENGINE_H
00003 
00004 #include "mbed.h"
00005 #include "N5110.h"
00006 #include "Gamepad.h"
00007 #include "Donkey.h"
00008 #include "Barrel.h"
00009 #include "Banana.h"
00010 #include "HighScores.h"
00011 #include "Options.h"
00012 
00013 /** GameEngine Class
00014 *@brief This class is running and contrling the main game functions.
00015 *@author Kern Fowler
00016 *@version 1.0
00017 *@date May 2019
00018 */
00019 
00020 class GameEngine {
00021 
00022 public: 
00023 /** GameEngine Constructor 
00024 @brief Builds my default GameEngine constructor.
00025 @details This does not have any setup. 
00026 */
00027 GameEngine();
00028 /** GameEngine Destructor 
00029 @brief Builds my default GameEngine destructor.
00030 @details This does not have any setup. 
00031 */
00032 ~GameEngine();
00033 // Mutators
00034 
00035 /** 
00036 *@brief Controls the main game.
00037 *@param pad The Gamepad class is used.
00038 *@param lcd The N5110 class is used.
00039 *@param barrel The Barrel class is used.
00040 *@param banana The Banana class is used.
00041 *@param dky The Donkey class is used.
00042 *@param opt The Options class is used.
00043 *@return None.
00044 *@details Runs the main functions of the game in correct order.
00045 *@code
00046 void GameEngine::gameengine_run(Gamepad &pad, N5110 &lcd, Barrel &barrel, Banana &banana, Donkey &dky, Options &opt) {
00047     wait_ms(250);
00048     // Sets key variables back to default value when game first ran.
00049     barrel_x = 0; 
00050     barrel_y = 0;
00051     banana_x = 0;
00052     banana_y = 0;
00053     running = 1;
00054     banana_time = 0;
00055     barrel_time = 0;
00056     score = 0;
00057     while (running == 1) { // Main game loop, continues until game over occurs.
00058         //printf("Game State");
00059         lcd.clear();
00060         dky.donkeykong_movement(pad, lcd); // Calls Donkey Kong model section of game.
00061         barrel.barrel_drop(pad, lcd, dky); // Calls Barrel model section of game.
00062         banana.banana_drop(pad, lcd, barrel, dky, opt); // Calls Banana model section of game.
00063         //printf("state %d", running);
00064         lcd.refresh(); // Reloads screen on every cycle, controlled by fps. Default set to 24.
00065         wait_ms(1.0f/24);
00066     }
00067 }
00068 @endcode
00069 */
00070 void gameengine_run(Gamepad &pad, N5110 &lcd, Barrel &barrel, Banana &banana, Donkey &dky, Options &opt);
00071 /** 
00072 *@brief Shows game over screen.
00073 *@param pad The Gamepad class is used.
00074 *@param lcd The N5110 class is used.
00075 *@param banana The Banana class is used.
00076 *@param high The HighScores class is used.
00077 *@return None.
00078 *@details Prints the gameover screen. Prints various text, including total player score.
00079 *@code
00080 void GameEngine::gameengine_score(Gamepad &pad, N5110 &lcd, Banana &banana, HighScores &high) {
00081     lcd.clear();
00082     lcd.printString("Game Over!",14,0);
00083     lcd.printString("Score:",0,2);
00084     char buffer[14]; // Shows final score on screen.
00085     sprintf(buffer,"%i",score);
00086     lcd.printString(buffer,40,2);
00087     high.highscores_new(pad, lcd, banana); // Checks to see if new high score is obtained.
00088     lcd.refresh();
00089     wait(5);
00090 }
00091 @endcode
00092 */
00093 void gameengine_score(Gamepad &pad, N5110 &lcd, Banana &banana, HighScores &high);
00094 };
00095 
00096 #endif