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.
Dependencies: mbed
Diff: TanksEngine/TanksEngine.h
- Revision:
- 21:44e87d88afe2
- Parent:
- 17:cb39d9fa08dc
- Child:
- 22:9e9685856ce1
diff -r 3c58ae38d6bc -r 44e87d88afe2 TanksEngine/TanksEngine.h --- a/TanksEngine/TanksEngine.h Tue May 07 12:42:15 2019 +0000 +++ b/TanksEngine/TanksEngine.h Thu May 09 13:10:16 2019 +0000 @@ -10,15 +10,83 @@ #include "Menus.h" #include "Scores.h" +/** TanksEngine class +@brief Class that holds the main game loop and game mechanics. It governs the + the use of game inputs like player actions through controls and game + outputs like updating the lcd, lighting LEDs and playing piezo tones. +@version 1.0 +@author Maxim C. Delacoe +@date April 2019 +@code + +#include "mbed.h" +#include "Gamepad.h" +#include "N5110.h" +#include "Bitmap.h" +#include "TanksEngine.h" +#include "Tank.h" +#include "Projectile.h" +#include "Graphics.h" +#include "Menus.h" +#include "Scores.h" + +N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); +TanksEngine engine; +Gamepad pad; +Graphics graphics; +Menus menus; +Scores scores; + +int main() +{ // need to initialise LCD and Gamepad + lcd.init(); + pad.init(); + + while(1) { // infinite loop + // Run start up screen and wait for player input. + menus.start_up_screen(graphics, lcd, pad); + // Run the menus and save any player preferences like mute enabled and + starting health for the tanks. + menus.main_menu(graphics, lcd, pad, scores); + // Initialise the game based on the players preferences. Setting starting + positions, health, etc. + engine.initgame(menus); + // Run the main game loop until a player reaches 0 health. + engine.game_loop(graphics, lcd, pad, menus, scores); + } +} + +@endcode +*/ class TanksEngine { public: - + // Constructor and destructor. + /** + * @brief Constructor + * @details Sets the movement limits and gravity's acceleration. + */ TanksEngine(); + /** + * @brief Destructor + * @details Non user specified. + */ ~TanksEngine(); - + + /** + * @brief Resets member variables to their default values from previous games and sets the values specified in setting. + * @param &menus * @details The menus object from Menus class. + */ void initgame(Menus &menus); + /** + * @brief Runs the main gameloop updating the game as the player inputs controls and updating display based on game events. + * @param &graphics * @details The graphics object from Graphics class. + * @param &lcd * @details The lcd object from N5110 class. + * @param &pad * @details The pad object from Gamepad class. + * @param &menus * @details The menus object from Menus class. + * @param &scores * @details The scores object from Scores class. + */ void game_loop(Graphics &graphics, N5110 &lcd, Gamepad &pad, Menus &menus, Scores &scores);