Yang Hongxiao 201199678
Dependencies: mbed
Control.h@1:a6ead8050c23, 2020-05-14 (annotated)
- Committer:
- YHX
- Date:
- Thu May 14 17:00:34 2020 +0000
- Revision:
- 1:a6ead8050c23
Yang Hongxiao; el17hy; 201199678
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
YHX | 1:a6ead8050c23 | 1 | #ifndef CONTROL_H |
YHX | 1:a6ead8050c23 | 2 | #define CONTROL_H |
YHX | 1:a6ead8050c23 | 3 | |
YHX | 1:a6ead8050c23 | 4 | #include "mbed.h" |
YHX | 1:a6ead8050c23 | 5 | #include "N5110.h" |
YHX | 1:a6ead8050c23 | 6 | #include "Gamepad.h" |
YHX | 1:a6ead8050c23 | 7 | #include "Bullet.h" |
YHX | 1:a6ead8050c23 | 8 | #include "Platform.h" |
YHX | 1:a6ead8050c23 | 9 | #include "Obstacle.h" |
YHX | 1:a6ead8050c23 | 10 | /** The control Class |
YHX | 1:a6ead8050c23 | 11 | * @brief This program define the control system |
YHX | 1:a6ead8050c23 | 12 | * @author Yang Hongxiao |
YHX | 1:a6ead8050c23 | 13 | * @date 15/5/2020 |
YHX | 1:a6ead8050c23 | 14 | */ |
YHX | 1:a6ead8050c23 | 15 | |
YHX | 1:a6ead8050c23 | 16 | class Control |
YHX | 1:a6ead8050c23 | 17 | { |
YHX | 1:a6ead8050c23 | 18 | |
YHX | 1:a6ead8050c23 | 19 | public: |
YHX | 1:a6ead8050c23 | 20 | /** Constructor */ |
YHX | 1:a6ead8050c23 | 21 | Control(); |
YHX | 1:a6ead8050c23 | 22 | /** Destructor */ |
YHX | 1:a6ead8050c23 | 23 | ~Control(); |
YHX | 1:a6ead8050c23 | 24 | /** Set the inital value |
YHX | 1:a6ead8050c23 | 25 | * @param the value of the platform width (nt platform_w),the value of the platform height (int platform), |
YHX | 1:a6ead8050c23 | 26 | * the value of bullet size(int r),the value of bullet spped(int vv), |
YHX | 1:a6ead8050c23 | 27 | */ |
YHX | 1:a6ead8050c23 | 28 | void init(int platform_w,int platform_h,int r,int vv); |
YHX | 1:a6ead8050c23 | 29 | /** Get the direction and magnitude |
YHX | 1:a6ead8050c23 | 30 | * @return the direction and magnitud |
YHX | 1:a6ead8050c23 | 31 | */ |
YHX | 1:a6ead8050c23 | 32 | void read_input(Gamepad &pad); |
YHX | 1:a6ead8050c23 | 33 | /** Set the update value |
YHX | 1:a6ead8050c23 | 34 | * @param none |
YHX | 1:a6ead8050c23 | 35 | */ |
YHX | 1:a6ead8050c23 | 36 | void update(Gamepad &pad); |
YHX | 1:a6ead8050c23 | 37 | /** draw the bullet,platform,obstacle,the screen edge |
YHX | 1:a6ead8050c23 | 38 | * @param the screen(N5110 &lcd) |
YHX | 1:a6ead8050c23 | 39 | */ |
YHX | 1:a6ead8050c23 | 40 | void draw(N5110 &lcd); |
YHX | 1:a6ead8050c23 | 41 | |
YHX | 1:a6ead8050c23 | 42 | |
YHX | 1:a6ead8050c23 | 43 | private: |
YHX | 1:a6ead8050c23 | 44 | |
YHX | 1:a6ead8050c23 | 45 | void check_wall_collision(Gamepad &pad); |
YHX | 1:a6ead8050c23 | 46 | void check_platform_collisions(Gamepad &pad); |
YHX | 1:a6ead8050c23 | 47 | void check_goal(Gamepad &pad); |
YHX | 1:a6ead8050c23 | 48 | void print_scores(N5110 &lcd); |
YHX | 1:a6ead8050c23 | 49 | void check__obstacle_collisios(Gamepad &pad); |
YHX | 1:a6ead8050c23 | 50 | |
YHX | 1:a6ead8050c23 | 51 | Platform _p; |
YHX | 1:a6ead8050c23 | 52 | Obstacle _o; |
YHX | 1:a6ead8050c23 | 53 | Bullet _bullet; |
YHX | 1:a6ead8050c23 | 54 | |
YHX | 1:a6ead8050c23 | 55 | int _platform_w; |
YHX | 1:a6ead8050c23 | 56 | int _platform_h; |
YHX | 1:a6ead8050c23 | 57 | int _r; |
YHX | 1:a6ead8050c23 | 58 | int _vv; |
YHX | 1:a6ead8050c23 | 59 | int _length; |
YHX | 1:a6ead8050c23 | 60 | |
YHX | 1:a6ead8050c23 | 61 | |
YHX | 1:a6ead8050c23 | 62 | Direction _d; |
YHX | 1:a6ead8050c23 | 63 | float _mag; |
YHX | 1:a6ead8050c23 | 64 | |
YHX | 1:a6ead8050c23 | 65 | }; |
YHX | 1:a6ead8050c23 | 66 | |
YHX | 1:a6ead8050c23 | 67 | #endif |