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@12:9e6d5d0a0c82, 2019-04-14 (annotated)
- Committer:
- el17mcd
- Date:
- Sun Apr 14 15:58:12 2019 +0000
- Revision:
- 12:9e6d5d0a0c82
- Parent:
- 11:4e2eb64031a0
- Child:
- 13:feadff02d3f7
! TankL class changed into generic Tank class. Separate graphics class to house and govern the use of sprites. Game now can produce two tanks on the screen facing opposite directions. They can take turns to fire projectiles based off joystick angle.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el17mcd | 7:a3ccabdebe2e | 1 | //#ifndef TANKENGINE_H |
el17mcd | 7:a3ccabdebe2e | 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 | 7:a3ccabdebe2e | 10 | |
el17mcd | 7:a3ccabdebe2e | 11 | class TanksEngine |
el17mcd | 7:a3ccabdebe2e | 12 | { |
el17mcd | 7:a3ccabdebe2e | 13 | public: |
el17mcd | 11:4e2eb64031a0 | 14 | |
el17mcd | 11:4e2eb64031a0 | 15 | TanksEngine(); |
el17mcd | 11:4e2eb64031a0 | 16 | ~TanksEngine(); |
el17mcd | 7:a3ccabdebe2e | 17 | |
el17mcd | 11:4e2eb64031a0 | 18 | void initgame(); |
el17mcd | 12:9e6d5d0a0c82 | 19 | void left_tank_turn(Gamepad &pad); |
el17mcd | 12:9e6d5d0a0c82 | 20 | void right_tank_turn(Gamepad &pad); |
el17mcd | 12:9e6d5d0a0c82 | 21 | void projectile_phase(); |
el17mcd | 12:9e6d5d0a0c82 | 22 | void read_input(Gamepad &pad); |
el17mcd | 12:9e6d5d0a0c82 | 23 | void render(Graphics graphics, N5110 &lcd); |
el17mcd | 11:4e2eb64031a0 | 24 | int get_turn(); |
el17mcd | 12:9e6d5d0a0c82 | 25 | void end(); |
el17mcd | 7:a3ccabdebe2e | 26 | |
el17mcd | 7:a3ccabdebe2e | 27 | private: |
el17mcd | 12:9e6d5d0a0c82 | 28 | |
el17mcd | 11:4e2eb64031a0 | 29 | void _left_tank_shoots(); |
el17mcd | 12:9e6d5d0a0c82 | 30 | void _right_tank_shoots(); |
el17mcd | 12:9e6d5d0a0c82 | 31 | bool _collision_pl(Tank _tankl, Projectile _proj); |
el17mcd | 11:4e2eb64031a0 | 32 | void _change_turn(); |
el17mcd | 12:9e6d5d0a0c82 | 33 | void _decrement_cooldowns(); |
el17mcd | 7:a3ccabdebe2e | 34 | |
el17mcd | 12:9e6d5d0a0c82 | 35 | int cooldownl; |
el17mcd | 12:9e6d5d0a0c82 | 36 | int cooldownr; |
el17mcd | 11:4e2eb64031a0 | 37 | int _turn; |
el17mcd | 11:4e2eb64031a0 | 38 | int _turn_timer; |
el17mcd | 11:4e2eb64031a0 | 39 | int _move; |
el17mcd | 11:4e2eb64031a0 | 40 | bool _fire; |
el17mcd | 11:4e2eb64031a0 | 41 | float _power; |
el17mcd | 11:4e2eb64031a0 | 42 | float _angle; |
el17mcd | 11:4e2eb64031a0 | 43 | float _mag; |
el17mcd | 11:4e2eb64031a0 | 44 | |
el17mcd | 12:9e6d5d0a0c82 | 45 | Tank _tankl; |
el17mcd | 12:9e6d5d0a0c82 | 46 | Tank _tankr; |
el17mcd | 11:4e2eb64031a0 | 47 | |
el17mcd | 11:4e2eb64031a0 | 48 | Projectile _proj; |
el17mcd | 7:a3ccabdebe2e | 49 | }; |
el17mcd | 7:a3ccabdebe2e | 50 |