Haoyan Zhang
/
el17h2z1
deemo1
StarcraftEngine/StarcraftEngine.h@1:8c48fb8ca5e0, 2020-05-11 (annotated)
- Committer:
- haoyan
- Date:
- Mon May 11 06:50:18 2020 +0000
- Revision:
- 1:8c48fb8ca5e0
- Child:
- 3:1db91ad3ab84
Finish
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
haoyan | 1:8c48fb8ca5e0 | 1 | #ifndef STARCRAFTENGINE_H |
haoyan | 1:8c48fb8ca5e0 | 2 | #define STARCRAFTENGINE_H |
haoyan | 1:8c48fb8ca5e0 | 3 | |
haoyan | 1:8c48fb8ca5e0 | 4 | #include "mbed.h" |
haoyan | 1:8c48fb8ca5e0 | 5 | #include "N5110.h" |
haoyan | 1:8c48fb8ca5e0 | 6 | #include "Gamepad.h" |
haoyan | 1:8c48fb8ca5e0 | 7 | #include "Battleship.h" |
haoyan | 1:8c48fb8ca5e0 | 8 | #include "Laser.h" |
haoyan | 1:8c48fb8ca5e0 | 9 | #include "Swarm.h" |
haoyan | 1:8c48fb8ca5e0 | 10 | |
haoyan | 1:8c48fb8ca5e0 | 11 | // gap from edge of screen |
haoyan | 1:8c48fb8ca5e0 | 12 | #define GAP 2 |
haoyan | 1:8c48fb8ca5e0 | 13 | |
haoyan | 1:8c48fb8ca5e0 | 14 | /** StarcraftEngine Class |
haoyan | 1:8c48fb8ca5e0 | 15 | @brief StarcraftEngine |
haoyan | 1:8c48fb8ca5e0 | 16 | @author Haoyan Zhang |
haoyan | 1:8c48fb8ca5e0 | 17 | @date May, 2020 |
haoyan | 1:8c48fb8ca5e0 | 18 | */ |
haoyan | 1:8c48fb8ca5e0 | 19 | |
haoyan | 1:8c48fb8ca5e0 | 20 | |
haoyan | 1:8c48fb8ca5e0 | 21 | class StarcraftEngine |
haoyan | 1:8c48fb8ca5e0 | 22 | { |
haoyan | 1:8c48fb8ca5e0 | 23 | |
haoyan | 1:8c48fb8ca5e0 | 24 | public: |
haoyan | 1:8c48fb8ca5e0 | 25 | StarcraftEngine(); |
haoyan | 1:8c48fb8ca5e0 | 26 | ~StarcraftEngine(); |
haoyan | 1:8c48fb8ca5e0 | 27 | |
haoyan | 1:8c48fb8ca5e0 | 28 | void init(int Battleship_height, int Battleship_width, int Laser_height, int Laser_width, int Swarm_height, int Swarm_width, int speed); |
haoyan | 1:8c48fb8ca5e0 | 29 | void read_input(Gamepad &pad); |
haoyan | 1:8c48fb8ca5e0 | 30 | int find_life(); |
haoyan | 1:8c48fb8ca5e0 | 31 | int find_score(); |
haoyan | 1:8c48fb8ca5e0 | 32 | void draw(N5110 &lcd); |
haoyan | 1:8c48fb8ca5e0 | 33 | void update(Gamepad &pad); |
haoyan | 1:8c48fb8ca5e0 | 34 | |
haoyan | 1:8c48fb8ca5e0 | 35 | private: |
haoyan | 1:8c48fb8ca5e0 | 36 | void check_Swarm_collisions(Gamepad &pad); |
haoyan | 1:8c48fb8ca5e0 | 37 | void check_goal(Gamepad &pad); |
haoyan | 1:8c48fb8ca5e0 | 38 | void print_scores(N5110 &lcd); |
haoyan | 1:8c48fb8ca5e0 | 39 | |
haoyan | 1:8c48fb8ca5e0 | 40 | Battleship _Battleship; |
haoyan | 1:8c48fb8ca5e0 | 41 | int _Battleship_height; |
haoyan | 1:8c48fb8ca5e0 | 42 | int _Battleship_width; |
haoyan | 1:8c48fb8ca5e0 | 43 | int _speed; |
haoyan | 1:8c48fb8ca5e0 | 44 | // x positions of the Battleship |
haoyan | 1:8c48fb8ca5e0 | 45 | int _Battleshipx; |
haoyan | 1:8c48fb8ca5e0 | 46 | |
haoyan | 1:8c48fb8ca5e0 | 47 | |
haoyan | 1:8c48fb8ca5e0 | 48 | Laser _Laser; |
haoyan | 1:8c48fb8ca5e0 | 49 | int _Laser_height; |
haoyan | 1:8c48fb8ca5e0 | 50 | int _Laser_width; |
haoyan | 1:8c48fb8ca5e0 | 51 | |
haoyan | 1:8c48fb8ca5e0 | 52 | Swarm _Swarm; |
haoyan | 1:8c48fb8ca5e0 | 53 | int _Swarm_height; |
haoyan | 1:8c48fb8ca5e0 | 54 | int _Swarm_width; |
haoyan | 1:8c48fb8ca5e0 | 55 | |
haoyan | 1:8c48fb8ca5e0 | 56 | Direction _d; |
haoyan | 1:8c48fb8ca5e0 | 57 | float _mag; |
haoyan | 1:8c48fb8ca5e0 | 58 | }; |
haoyan | 1:8c48fb8ca5e0 | 59 | #endif |
haoyan | 1:8c48fb8ca5e0 | 60 | |
haoyan | 1:8c48fb8ca5e0 | 61 | |
haoyan | 1:8c48fb8ca5e0 | 62 | |
haoyan | 1:8c48fb8ca5e0 | 63 | |
haoyan | 1:8c48fb8ca5e0 | 64 | |
haoyan | 1:8c48fb8ca5e0 | 65 | |
haoyan | 1:8c48fb8ca5e0 | 66 |