Mochu Yao explorer game
Dependencies: mbed
explorer/explorer.h
- Committer:
- el17my
- Date:
- 2020-04-20
- Revision:
- 2:89f04cd3bf45
- Child:
- 3:672d4bd8225d
File content as of revision 2:89f04cd3bf45:
#ifndef EXPLORER_H #define EXPLORER_H #include "mbed.h" #include "Gamepad.h" //use the enum to define the value we need for the explorer enum Respond_value{ Move_right, Move_left, Stand_left, Stand_right, }; //the explorer's direction enum Player_direction { right, left }; /** explorer Class * @the explorer class has three functions 1 the movement of a explorer to jump and move in left or right direction 2 check fallen and collision 3 reset the game * @date April 15th 2020 * @author Yaomochu @code #include "mbed.h" #include "N5110.h" #include "Gamepad.h" #include "explorer.h" #include <cstdlib> #include <ctime> Gamepad gamepad; N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Explorer _player; int _player_x; int _player_y; int _level; bool _start_line_flag; bool _f_flag; int _move_counter; int _jump_counter; Player_direction _player_direction; Respond_value _respond_sprite; int main() { _start_line_flag = true; _fall_flag = false; _player_direction = left; _player.r_flag(false); _move_counter = 0; _jump_counter = 15; while(1) { // Y coordinate if (_f_flag) { _player.fall(_f_flag, gamepad); } else { _player.set_y_coordinate(false, _jump_counter, _level, gamepad); } _f_flag = _player._f_flag(); _player_y = _player.get_y_(); _jump_counter = _player.get_j_counter(); // X coordinate _player.set_x_coordinate(1, _move_counter, _direction,1); _player_x = _player.get_x(); _move_counter = player.get_m_counter(); //change in to a new direction. _direction = _get_direction(); lcd.drawSprite(_player_x,_player_y,20,10,(int *)_player.get_sprite(_respond_sprite)); } } @endcode */ class Explorer { public: explorer(); //Constructor ~explorer(); //Destructor void set_x_coordinate(float joystick_x, int move, Player_direction direction, float joystick_y); void reset_flag(bool flag); void set_y_coordinate(bool ifjump, int jump_counter, int level, Gamepad &gamepad); int get_y(); int get_x(); int get_m_counter(); int get_j_counter(); bool get_f_flag(); bool get_r_flag(); Respond_value get_respond_value Player_direction get_direction(); int * get_respond(Respond_value respond); void fall(bool f_flag, Gamepad &gamepad); private: void change_x(float joystick_x); int _x; int _y; int _move_counter; int _level; int _jump_counter; bool _f_flag; bool _r_flag; Player_direction _player_direction; Respond_value _respond_value; }; #endif