Yang Zhenye 201199680
Dependencies: mbed
RooneyEngine/RooneyEngine.h@9:a5a82b3d1102, 2020-05-15 (annotated)
- Committer:
- yangzhenye
- Date:
- Fri May 15 07:27:23 2020 +0000
- Revision:
- 9:a5a82b3d1102
- Parent:
- 8:c02c278320c0
el17zy Yang Zhenye
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yangzhenye | 9:a5a82b3d1102 | 1 | |
yangzhenye | 5:fcad75e9b9e1 | 2 | #ifndef ROONEYENGINE_H |
yangzhenye | 5:fcad75e9b9e1 | 3 | #define ROONEYENGIN_H |
yangzhenye | 3:30c81344beff | 4 | |
yangzhenye | 3:30c81344beff | 5 | #include "mbed.h" |
yangzhenye | 3:30c81344beff | 6 | #include "N5110.h" |
yangzhenye | 3:30c81344beff | 7 | #include "Gamepad.h" |
yangzhenye | 4:eb8dca1dc341 | 8 | #include "Rooney.h" |
yangzhenye | 3:30c81344beff | 9 | #include "Ball.h" |
yangzhenye | 9:a5a82b3d1102 | 10 | /** control struct */ |
yangzhenye | 9:a5a82b3d1102 | 11 | struct control { |
yangzhenye | 9:a5a82b3d1102 | 12 | Vector2D c; /**< Vector 2D for joystick x */ |
yangzhenye | 9:a5a82b3d1102 | 13 | }; |
yangzhenye | 9:a5a82b3d1102 | 14 | /** RooneyEngine class |
yangzhenye | 9:a5a82b3d1102 | 15 | * @1 make the whole game run and set the score the reset process |
yangzhenye | 9:a5a82b3d1102 | 16 | * @2 cheak the collision and the reset or fall flag |
yangzhenye | 9:a5a82b3d1102 | 17 | * @3 draw on the lcd screen and load the gamepad controll |
yangzhenye | 9:a5a82b3d1102 | 18 | * @date May 14th 2020 |
yangzhenye | 9:a5a82b3d1102 | 19 | * @author Yang Zhenye |
yangzhenye | 9:a5a82b3d1102 | 20 | |
yangzhenye | 9:a5a82b3d1102 | 21 | @ code |
yangzhenye | 9:a5a82b3d1102 | 22 | |
yangzhenye | 9:a5a82b3d1102 | 23 | #include "mbed.h" |
yangzhenye | 9:a5a82b3d1102 | 24 | #include "N5110.h" |
yangzhenye | 9:a5a82b3d1102 | 25 | #include "Gamepad.h" |
yangzhenye | 9:a5a82b3d1102 | 26 | #include "RooneyEngine.h" |
yangzhenye | 9:a5a82b3d1102 | 27 | @endcode |
yangzhenye | 9:a5a82b3d1102 | 28 | */ |
yangzhenye | 9:a5a82b3d1102 | 29 | |
yangzhenye | 9:a5a82b3d1102 | 30 | |
yangzhenye | 9:a5a82b3d1102 | 31 | |
yangzhenye | 3:30c81344beff | 32 | |
yangzhenye | 4:eb8dca1dc341 | 33 | class RooneyEngine{ |
yangzhenye | 3:30c81344beff | 34 | public: |
yangzhenye | 5:fcad75e9b9e1 | 35 | // Constructor and destructor. |
yangzhenye | 5:fcad75e9b9e1 | 36 | /** |
yangzhenye | 5:fcad75e9b9e1 | 37 | * @brief Constructor @details Non user specified. |
yangzhenye | 5:fcad75e9b9e1 | 38 | */ |
yangzhenye | 4:eb8dca1dc341 | 39 | RooneyEngine(); |
yangzhenye | 5:fcad75e9b9e1 | 40 | /** |
yangzhenye | 5:fcad75e9b9e1 | 41 | * @brief Destructor @details Non user specified. |
yangzhenye | 5:fcad75e9b9e1 | 42 | */ |
yangzhenye | 4:eb8dca1dc341 | 43 | ~RooneyEngine(); |
yangzhenye | 9:a5a82b3d1102 | 44 | // Mutators. |
yangzhenye | 9:a5a82b3d1102 | 45 | /** |
yangzhenye | 9:a5a82b3d1102 | 46 | * @brief Initalises the RooneyEngine |
yangzhenye | 9:a5a82b3d1102 | 47 | */ |
yangzhenye | 3:30c81344beff | 48 | void init(); |
yangzhenye | 9:a5a82b3d1102 | 49 | /** |
yangzhenye | 9:a5a82b3d1102 | 50 | * @brief reset the RooneyEngine. |
yangzhenye | 9:a5a82b3d1102 | 51 | */ |
yangzhenye | 3:30c81344beff | 52 | void reset(); |
yangzhenye | 9:a5a82b3d1102 | 53 | /** |
yangzhenye | 9:a5a82b3d1102 | 54 | * @brief get the coordinate and the button_flag. |
yangzhenye | 9:a5a82b3d1102 | 55 | * @param &gamepad @details The gamepad object from Gamepad class. |
yangzhenye | 9:a5a82b3d1102 | 56 | */ |
yangzhenye | 9:a5a82b3d1102 | 57 | void read_input(Gamepad &pad); |
yangzhenye | 9:a5a82b3d1102 | 58 | /** |
yangzhenye | 9:a5a82b3d1102 | 59 | * @brief check and flesh the reset flag. |
yangzhenye | 9:a5a82b3d1102 | 60 | * @param &gamepad @details The gamepad object from Gamepad class. |
yangzhenye | 9:a5a82b3d1102 | 61 | * @param &lcd @details The lcd object from the N5110 class |
yangzhenye | 9:a5a82b3d1102 | 62 | */ |
yangzhenye | 3:30c81344beff | 63 | void check_reset(N5110 &lcd, Gamepad &gamepad); |
yangzhenye | 9:a5a82b3d1102 | 64 | /** |
yangzhenye | 9:a5a82b3d1102 | 65 | * @brief check and flesh the start flag. |
yangzhenye | 9:a5a82b3d1102 | 66 | * @param &gamepad @details The gamepad object from Gamepad class. |
yangzhenye | 9:a5a82b3d1102 | 67 | * @param &lcd @details The lcd object from the N5110 class |
yangzhenye | 9:a5a82b3d1102 | 68 | */ |
yangzhenye | 3:30c81344beff | 69 | void check_start(N5110 &lcd, Gamepad &gamepad); |
yangzhenye | 9:a5a82b3d1102 | 70 | /** |
yangzhenye | 9:a5a82b3d1102 | 71 | * @brief check and flesh the collision flag. |
yangzhenye | 9:a5a82b3d1102 | 72 | * @param &gamepad @details The gamepad object from Gamepad class. |
yangzhenye | 9:a5a82b3d1102 | 73 | */ |
yangzhenye | 3:30c81344beff | 74 | void check_collision(Gamepad &gamepad); |
yangzhenye | 9:a5a82b3d1102 | 75 | /** |
yangzhenye | 9:a5a82b3d1102 | 76 | * @brief get the player score. |
yangzhenye | 9:a5a82b3d1102 | 77 | */ |
yangzhenye | 9:a5a82b3d1102 | 78 | int get_score(); |
yangzhenye | 9:a5a82b3d1102 | 79 | /** |
yangzhenye | 9:a5a82b3d1102 | 80 | * @brief get the player speed. |
yangzhenye | 9:a5a82b3d1102 | 81 | */ |
yangzhenye | 9:a5a82b3d1102 | 82 | int get_speed(); |
yangzhenye | 9:a5a82b3d1102 | 83 | /** |
yangzhenye | 9:a5a82b3d1102 | 84 | * @brief get the sprite. |
yangzhenye | 9:a5a82b3d1102 | 85 | */ |
yangzhenye | 9:a5a82b3d1102 | 86 | void get_sprite(N5110 &lcd); |
yangzhenye | 9:a5a82b3d1102 | 87 | /** |
yangzhenye | 9:a5a82b3d1102 | 88 | * @brief Updates the LCD display. |
yangzhenye | 9:a5a82b3d1102 | 89 | * @param &lcd @details The lcd object from the N5110 class. |
yangzhenye | 9:a5a82b3d1102 | 90 | */ |
yangzhenye | 3:30c81344beff | 91 | void update_lcd(N5110 &lcd); |
yangzhenye | 9:a5a82b3d1102 | 92 | /** |
yangzhenye | 9:a5a82b3d1102 | 93 | * @brief run the game. |
yangzhenye | 9:a5a82b3d1102 | 94 | */ |
yangzhenye | 3:30c81344beff | 95 | void run_engine(N5110 &lcd, Gamepad &gamepad); |
yangzhenye | 9:a5a82b3d1102 | 96 | /** |
yangzhenye | 9:a5a82b3d1102 | 97 | * @brief get the reset flag. |
yangzhenye | 9:a5a82b3d1102 | 98 | */ |
yangzhenye | 3:30c81344beff | 99 | bool get_reset_flag(); |
yangzhenye | 9:a5a82b3d1102 | 100 | /** |
yangzhenye | 9:a5a82b3d1102 | 101 | * @brief get the start flag. |
yangzhenye | 9:a5a82b3d1102 | 102 | */ |
yangzhenye | 3:30c81344beff | 103 | bool get_start_flag(); |
yangzhenye | 9:a5a82b3d1102 | 104 | /** |
yangzhenye | 9:a5a82b3d1102 | 105 | * @brief get player's x |
yangzhenye | 9:a5a82b3d1102 | 106 | */ |
yangzhenye | 9:a5a82b3d1102 | 107 | void get_rooney_x(Gamepad &gamepad,int speed,float joy_x); |
yangzhenye | 3:30c81344beff | 108 | private: |
yangzhenye | 9:a5a82b3d1102 | 109 | control _control; |
yangzhenye | 9:a5a82b3d1102 | 110 | player _player; |
yangzhenye | 9:a5a82b3d1102 | 111 | rooneybody body; |
yangzhenye | 3:30c81344beff | 112 | int _player_x; |
yangzhenye | 3:30c81344beff | 113 | int _player_y; |
yangzhenye | 3:30c81344beff | 114 | int _x; |
yangzhenye | 3:30c81344beff | 115 | int _y; |
yangzhenye | 3:30c81344beff | 116 | bool _collision_flag; |
yangzhenye | 3:30c81344beff | 117 | bool _start_flag; |
yangzhenye | 3:30c81344beff | 118 | bool _reset_flag; |
yangzhenye | 3:30c81344beff | 119 | int _speed; |
yangzhenye | 3:30c81344beff | 120 | int _player_score; |
yangzhenye | 5:fcad75e9b9e1 | 121 | }; |
yangzhenye | 3:30c81344beff | 122 | #endif |
yangzhenye | 3:30c81344beff | 123 |