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