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/TanksEngine.h@17:cb39d9fa08dc, 2019-04-27 (annotated)
- Committer:
- el17mcd
- Date:
- Sat Apr 27 17:43:46 2019 +0000
- Revision:
- 17:cb39d9fa08dc
- Parent:
- 16:a2c945279b79
- Child:
- 21:44e87d88afe2
! Stylistic changes made to code so it conforms to google c++ guide. Beginning of inline commenting of source code.
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| el17mcd | 16:a2c945279b79 | 1 | #ifndef TANKENGINE_H | 
| el17mcd | 16:a2c945279b79 | 2 | #define TANKENGINE_H | 
| el17mcd | 7:a3ccabdebe2e | 3 | |
| el17mcd | 7:a3ccabdebe2e | 4 | #include "mbed.h" | 
| el17mcd | 7:a3ccabdebe2e | 5 | #include "N5110.h" | 
| el17mcd | 7:a3ccabdebe2e | 6 | #include "Gamepad.h" | 
| el17mcd | 7:a3ccabdebe2e | 7 | #include "Projectile.h" | 
| el17mcd | 12:9e6d5d0a0c82 | 8 | #include "Tank.h" | 
| el17mcd | 12:9e6d5d0a0c82 | 9 | #include "Graphics.h" | 
| el17mcd | 15:fa5282fcd134 | 10 | #include "Menus.h" | 
| el17mcd | 16:a2c945279b79 | 11 | #include "Scores.h" | 
| el17mcd | 7:a3ccabdebe2e | 12 | |
| el17mcd | 7:a3ccabdebe2e | 13 | class TanksEngine | 
| el17mcd | 7:a3ccabdebe2e | 14 | { | 
| el17mcd | 16:a2c945279b79 | 15 | |
| el17mcd | 7:a3ccabdebe2e | 16 | public: | 
| el17mcd | 11:4e2eb64031a0 | 17 | |
| el17mcd | 17:cb39d9fa08dc | 18 | TanksEngine(); | 
| el17mcd | 17:cb39d9fa08dc | 19 | ~TanksEngine(); | 
| el17mcd | 16:a2c945279b79 | 20 | |
| el17mcd | 17:cb39d9fa08dc | 21 | void initgame(Menus &menus); | 
| el17mcd | 17:cb39d9fa08dc | 22 | void game_loop(Graphics &graphics, N5110 &lcd, Gamepad &pad, | 
| el17mcd | 17:cb39d9fa08dc | 23 | Menus &menus, Scores &scores); | 
| el17mcd | 7:a3ccabdebe2e | 24 | |
| el17mcd | 7:a3ccabdebe2e | 25 | private: | 
| el17mcd | 12:9e6d5d0a0c82 | 26 | |
| el17mcd | 16:a2c945279b79 | 27 | // Game Flow | 
| el17mcd | 17:cb39d9fa08dc | 28 | void _left_tank_turn(Graphics &graphics, Gamepad &pad); | 
| el17mcd | 17:cb39d9fa08dc | 29 | void _right_tank_turn(Graphics &graphics, Gamepad &pad); | 
| el17mcd | 17:cb39d9fa08dc | 30 | void _projectile_phase(N5110 &lcd, Gamepad &pad); | 
| el17mcd | 17:cb39d9fa08dc | 31 | void _change_turn(); | 
| el17mcd | 17:cb39d9fa08dc | 32 | void _end(Graphics &graphics, N5110 &lcd, Gamepad &pad, Scores &scores); | 
| el17mcd | 16:a2c945279b79 | 33 | // Game Mechanics | 
| el17mcd | 17:cb39d9fa08dc | 34 | void _tank_shoots(int x, int y, int turn, Gamepad &pad); | 
| el17mcd | 17:cb39d9fa08dc | 35 | void _object_hit(int x, int y, N5110 &lcd, Gamepad &pad); | 
| el17mcd | 17:cb39d9fa08dc | 36 | bool _collision_pl(Tank _tankl, Projectile _proj); | 
| el17mcd | 17:cb39d9fa08dc | 37 | bool _collision_pr(Tank _tankr, Projectile _proj); | 
| el17mcd | 17:cb39d9fa08dc | 38 | bool _collision_pm(int x, int y, N5110 &lcd, Projectile _proj); | 
| el17mcd | 16:a2c945279b79 | 39 | // Game Inputs | 
| el17mcd | 17:cb39d9fa08dc | 40 | void _read_input(Gamepad &pad); | 
| el17mcd | 17:cb39d9fa08dc | 41 | void _decrement_cooldowns(); | 
| el17mcd | 16:a2c945279b79 | 42 | // Game Outputs | 
| el17mcd | 17:cb39d9fa08dc | 43 | void _draw(Graphics graphics, N5110 &lcd); | 
| el17mcd | 17:cb39d9fa08dc | 44 | void _sounds(int n, Gamepad &pad); | 
| el17mcd | 16:a2c945279b79 | 45 | |
| el17mcd | 17:cb39d9fa08dc | 46 | Tank _tankl; | 
| el17mcd | 17:cb39d9fa08dc | 47 | Tank _tankr; | 
| el17mcd | 7:a3ccabdebe2e | 48 | |
| el17mcd | 17:cb39d9fa08dc | 49 | Projectile _proj; | 
| el17mcd | 16:a2c945279b79 | 50 | |
| el17mcd | 17:cb39d9fa08dc | 51 | int _initial_health; | 
| el17mcd | 17:cb39d9fa08dc | 52 | int _cooldown_l; | 
| el17mcd | 17:cb39d9fa08dc | 53 | int _cooldown_r; | 
| el17mcd | 17:cb39d9fa08dc | 54 | int _move; | 
| el17mcd | 17:cb39d9fa08dc | 55 | int _turn; | 
| el17mcd | 17:cb39d9fa08dc | 56 | int _turn_counter; | 
| el17mcd | 17:cb39d9fa08dc | 57 | bool _fire; | 
| el17mcd | 17:cb39d9fa08dc | 58 | bool _mute; | 
| el17mcd | 17:cb39d9fa08dc | 59 | float _angle; | 
| el17mcd | 17:cb39d9fa08dc | 60 | float _mag; | 
| el17mcd | 17:cb39d9fa08dc | 61 | float _vel; | 
| el17mcd | 17:cb39d9fa08dc | 62 | float _grav; | 
| el17mcd | 17:cb39d9fa08dc | 63 | float _wind; | 
| el17mcd | 7:a3ccabdebe2e | 64 | }; | 
| el17mcd | 7:a3ccabdebe2e | 65 | |
| el17mcd | 16:a2c945279b79 | 66 | #endif // TANKSENGINE_H |