Zhang Xin yu
/
ZhangXinyu201090208
zhangxinyu01text
cxkEngine/cxkEngine.h@12:3952ba0683c7, 2019-05-06 (annotated)
- Committer:
- Jenny121
- Date:
- Mon May 06 06:09:02 2019 +0000
- Revision:
- 12:3952ba0683c7
zhang xinyu
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jenny121 | 12:3952ba0683c7 | 1 | #ifndef cxkEngine_H |
Jenny121 | 12:3952ba0683c7 | 2 | #define cxkEngine_H |
Jenny121 | 12:3952ba0683c7 | 3 | |
Jenny121 | 12:3952ba0683c7 | 4 | #include "mbed.h" |
Jenny121 | 12:3952ba0683c7 | 5 | #include "N5110.h" |
Jenny121 | 12:3952ba0683c7 | 6 | #include "Gamepad.h" |
Jenny121 | 12:3952ba0683c7 | 7 | #include "Ball.h" |
Jenny121 | 12:3952ba0683c7 | 8 | #include "CXK.h" |
Jenny121 | 12:3952ba0683c7 | 9 | |
Jenny121 | 12:3952ba0683c7 | 10 | |
Jenny121 | 12:3952ba0683c7 | 11 | /** cxkEngine Class |
Jenny121 | 12:3952ba0683c7 | 12 | * @brief the diagram of the ball and others |
Jenny121 | 12:3952ba0683c7 | 13 | * @author Zhang Xinyu |
Jenny121 | 12:3952ba0683c7 | 14 | * @school EE of SWJTU &leeds joint school |
Jenny121 | 12:3952ba0683c7 | 15 | * @date MAY 2019 |
Jenny121 | 12:3952ba0683c7 | 16 | */ |
Jenny121 | 12:3952ba0683c7 | 17 | |
Jenny121 | 12:3952ba0683c7 | 18 | class cxkEngine |
Jenny121 | 12:3952ba0683c7 | 19 | { |
Jenny121 | 12:3952ba0683c7 | 20 | |
Jenny121 | 12:3952ba0683c7 | 21 | public: |
Jenny121 | 12:3952ba0683c7 | 22 | |
Jenny121 | 12:3952ba0683c7 | 23 | /** Constructor */ |
Jenny121 | 12:3952ba0683c7 | 24 | cxkEngine(); |
Jenny121 | 12:3952ba0683c7 | 25 | |
Jenny121 | 12:3952ba0683c7 | 26 | /** Destrctor */ |
Jenny121 | 12:3952ba0683c7 | 27 | ~cxkEngine(); |
Jenny121 | 12:3952ba0683c7 | 28 | |
Jenny121 | 12:3952ba0683c7 | 29 | /** Set the cxkEngineinit |
Jenny121 | 12:3952ba0683c7 | 30 | * @ param value of the cxk feature of the CXK file (CXK_width, CXK_height) |
Jenny121 | 12:3952ba0683c7 | 31 | * @ param value of the ball size of the ballfile (ball_size) |
Jenny121 | 12:3952ba0683c7 | 32 | * @ param value of the move speed of the CXKand ball file (speed) |
Jenny121 | 12:3952ba0683c7 | 33 | */ |
Jenny121 | 12:3952ba0683c7 | 34 | void init(int CXK_width,int CXK_height,int ball_size,int speed); |
Jenny121 | 12:3952ba0683c7 | 35 | |
Jenny121 | 12:3952ba0683c7 | 36 | /** Set the cxkEread_Iinput |
Jenny121 | 12:3952ba0683c7 | 37 | * @ details use CXK and BAll to read the value of direction and maganitude of joystick |
Jenny121 | 12:3952ba0683c7 | 38 | */ |
Jenny121 | 12:3952ba0683c7 | 39 | void read_input(Gamepad &pad); |
Jenny121 | 12:3952ba0683c7 | 40 | |
Jenny121 | 12:3952ba0683c7 | 41 | |
Jenny121 | 12:3952ba0683c7 | 42 | /** Set the cxkEupdate |
Jenny121 | 12:3952ba0683c7 | 43 | * @ details updated the d and vara from the read_input |
Jenny121 | 12:3952ba0683c7 | 44 | */ |
Jenny121 | 12:3952ba0683c7 | 45 | void update(Gamepad &pad); |
Jenny121 | 12:3952ba0683c7 | 46 | |
Jenny121 | 12:3952ba0683c7 | 47 | /** Set the CXKdraw |
Jenny121 | 12:3952ba0683c7 | 48 | * @ param the score player get (cxkp_score) |
Jenny121 | 12:3952ba0683c7 | 49 | * @ details draw the wall and basket to the game |
Jenny121 | 12:3952ba0683c7 | 50 | */ |
Jenny121 | 12:3952ba0683c7 | 51 | void draw(N5110 &lcd); |
Jenny121 | 12:3952ba0683c7 | 52 | |
Jenny121 | 12:3952ba0683c7 | 53 | private: |
Jenny121 | 12:3952ba0683c7 | 54 | |
Jenny121 | 12:3952ba0683c7 | 55 | void check_wall_collision(Gamepad &pad); |
Jenny121 | 12:3952ba0683c7 | 56 | void check_CXK_collisions(Gamepad &pad); |
Jenny121 | 12:3952ba0683c7 | 57 | void check_goal(Gamepad &pad); |
Jenny121 | 12:3952ba0683c7 | 58 | void print_scores(N5110 &lcd); |
Jenny121 | 12:3952ba0683c7 | 59 | |
Jenny121 | 12:3952ba0683c7 | 60 | |
Jenny121 | 12:3952ba0683c7 | 61 | CXK _cxkp; |
Jenny121 | 12:3952ba0683c7 | 62 | |
Jenny121 | 12:3952ba0683c7 | 63 | int _CXK_width; |
Jenny121 | 12:3952ba0683c7 | 64 | int _CXK_height; |
Jenny121 | 12:3952ba0683c7 | 65 | int _ball_size; |
Jenny121 | 12:3952ba0683c7 | 66 | int _speed; |
Jenny121 | 12:3952ba0683c7 | 67 | int _direction; |
Jenny121 | 12:3952ba0683c7 | 68 | |
Jenny121 | 12:3952ba0683c7 | 69 | // xy positions of theCXKs |
Jenny121 | 12:3952ba0683c7 | 70 | ///////// |
Jenny121 | 12:3952ba0683c7 | 71 | int _cxkpx; |
Jenny121 | 12:3952ba0683c7 | 72 | int _cxkpy; |
Jenny121 | 12:3952ba0683c7 | 73 | |
Jenny121 | 12:3952ba0683c7 | 74 | Ball _ball; |
Jenny121 | 12:3952ba0683c7 | 75 | |
Jenny121 | 12:3952ba0683c7 | 76 | Direction _d; |
Jenny121 | 12:3952ba0683c7 | 77 | float _vara; |
Jenny121 | 12:3952ba0683c7 | 78 | |
Jenny121 | 12:3952ba0683c7 | 79 | }; |
Jenny121 | 12:3952ba0683c7 | 80 | |
Jenny121 | 12:3952ba0683c7 | 81 | #endif |