Mochu Yao explorer game
Dependencies: mbed
explorer/explorer.h@3:672d4bd8225d, 2020-04-21 (annotated)
- Committer:
- el17my
- Date:
- Tue Apr 21 12:31:27 2020 +0000
- Revision:
- 3:672d4bd8225d
- Parent:
- 2:89f04cd3bf45
- Child:
- 4:64746224ab6e
creating the line on the screen
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el17my | 3:672d4bd8225d | 1 | /** explorer |
el17my | 3:672d4bd8225d | 2 | * @the explorer file has three functions |
el17my | 3:672d4bd8225d | 3 | 1 the movement of a explorer to jump and move in left or right direction |
el17my | 3:672d4bd8225d | 4 | 2 check fallen and collision |
el17my | 3:672d4bd8225d | 5 | 3 reset the game |
el17my | 3:672d4bd8225d | 6 | * @date April 15th 2020 |
el17my | 3:672d4bd8225d | 7 | * @author Yaomochu |
el17my | 3:672d4bd8225d | 8 | */ |
el17my | 2:89f04cd3bf45 | 9 | #ifndef EXPLORER_H |
el17my | 2:89f04cd3bf45 | 10 | #define EXPLORER_H |
el17my | 2:89f04cd3bf45 | 11 | |
el17my | 2:89f04cd3bf45 | 12 | #include "mbed.h" |
el17my | 2:89f04cd3bf45 | 13 | #include "Gamepad.h" |
el17my | 2:89f04cd3bf45 | 14 | //use the enum to define the value we need for the explorer |
el17my | 3:672d4bd8225d | 15 | enum explorer_sprite{Move_right,Move_left,Stand_left, Stand_right}; |
el17my | 3:672d4bd8225d | 16 | //we have four sprite form so we can define the sprite on the screen by using these enum |
el17my | 2:89f04cd3bf45 | 17 | //the explorer's direction |
el17my | 3:672d4bd8225d | 18 | enum Player_direction {right,left}; |
el17my | 2:89f04cd3bf45 | 19 | |
el17my | 2:89f04cd3bf45 | 20 | class Explorer { |
el17my | 2:89f04cd3bf45 | 21 | public: |
el17my | 3:672d4bd8225d | 22 | Explorer(); |
el17my | 2:89f04cd3bf45 | 23 | //Constructor |
el17my | 3:672d4bd8225d | 24 | ~Explorer(); |
el17my | 2:89f04cd3bf45 | 25 | //Destructor |
el17my | 3:672d4bd8225d | 26 | void set_x_coordinate(float joy_x, int speed, Player_direction direction); |
el17my | 3:672d4bd8225d | 27 | void set_y_coordinate(bool ifjump, int jump_height, int level); |
el17my | 2:89f04cd3bf45 | 28 | int get_y(); |
el17my | 2:89f04cd3bf45 | 29 | |
el17my | 2:89f04cd3bf45 | 30 | int get_x(); |
el17my | 2:89f04cd3bf45 | 31 | |
el17my | 3:672d4bd8225d | 32 | int get_speed(); |
el17my | 2:89f04cd3bf45 | 33 | |
el17my | 3:672d4bd8225d | 34 | int get_jump_height(); |
el17my | 2:89f04cd3bf45 | 35 | |
el17my | 2:89f04cd3bf45 | 36 | Player_direction get_direction(); |
el17my | 2:89f04cd3bf45 | 37 | |
el17my | 3:672d4bd8225d | 38 | explorer_sprite get_explorer_sprite(); |
el17my | 3:672d4bd8225d | 39 | |
el17my | 3:672d4bd8225d | 40 | int * get_form(explorer_sprite sprite); |
el17my | 3:672d4bd8225d | 41 | //this function is used to get the players form and print on the screen (same as the item file) |
el17my | 2:89f04cd3bf45 | 42 | |
el17my | 2:89f04cd3bf45 | 43 | void fall(bool f_flag, Gamepad &gamepad); |
el17my | 3:672d4bd8225d | 44 | //the fall flag need to add music to hint the player that the game is over |
el17my | 3:672d4bd8225d | 45 | void reset_flag(bool reset_flag,Gamepad &gamepad); |
el17my | 3:672d4bd8225d | 46 | //the reset flag also need to add music to hint the player that the game has been reseted |
el17my | 3:672d4bd8225d | 47 | bool get_fall_flag(); |
el17my | 3:672d4bd8225d | 48 | |
el17my | 3:672d4bd8225d | 49 | bool get_reset_flag(); |
el17my | 2:89f04cd3bf45 | 50 | |
el17my | 2:89f04cd3bf45 | 51 | private: |
el17my | 2:89f04cd3bf45 | 52 | |
el17my | 2:89f04cd3bf45 | 53 | int _x; |
el17my | 2:89f04cd3bf45 | 54 | int _y; |
el17my | 3:672d4bd8225d | 55 | int _speed; |
el17my | 2:89f04cd3bf45 | 56 | int _level; |
el17my | 3:672d4bd8225d | 57 | int _jump_height; |
el17my | 2:89f04cd3bf45 | 58 | bool _f_flag; |
el17my | 2:89f04cd3bf45 | 59 | bool _r_flag; |
el17my | 2:89f04cd3bf45 | 60 | Player_direction _player_direction; |
el17my | 3:672d4bd8225d | 61 | explorer_sprite _sprite |
el17my | 2:89f04cd3bf45 | 62 | }; |
el17my | 2:89f04cd3bf45 | 63 | #endif |