444444444444

Dependencies:   mbed CXK

Committer:
Jenny121
Date:
Mon May 06 06:42:41 2019 +0000
Revision:
13:45354ed42401
Parent:
12:f8eb397226bc
1122

Who changed what in which revision?

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