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
TanksEngine Class Reference
TanksEngine class. More...
#include <TanksEngine.h>
Public Member Functions | |
| TanksEngine () | |
| Constructor. | |
| ~TanksEngine () | |
| Destructor. | |
| void | initgame (Menus &menus) |
| Resets member variables from previous games to their default values and sets the values specified in setting. | |
| void | game_loop (Graphics &graphics, N5110 &lcd, Gamepad &pad, Menus &menus, Scores &scores) |
| Runs the main gameloop updating the game as the player inputs controls and updating display based on game events. | |
Detailed Description
TanksEngine class.
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
- Date:
- April 2019
#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); } }
Definition at line 61 of file TanksEngine.h.
Constructor & Destructor Documentation
| TanksEngine | ( | ) |
Constructor.
Sets the movement limits and gravity's acceleration.
Definition at line 7 of file TanksEngine.cpp.
| ~TanksEngine | ( | ) |
Member Function Documentation
Runs the main gameloop updating the game as the player inputs controls and updating display based on game events.
- Parameters:
-
graphics *
The graphics object from Graphics class.
- Parameters:
-
lcd *
The lcd object from N5110 class.
- Parameters:
-
pad *
The pad object from Gamepad class.
- Parameters:
-
menus *
The menus object from Menus class.
- Parameters:
-
scores *
The scores object from Scores class.
Definition at line 40 of file TanksEngine.cpp.
| void initgame | ( | Menus & | menus ) |
Resets member variables from previous games to their default values and sets the values specified in setting.
- Parameters:
-
menus *
The menus object from Menus class.
Definition at line 20 of file TanksEngine.cpp.
Generated on Thu Jul 14 2022 01:14:35 by
1.7.2