Mochu Yao explorer game

Dependencies:   mbed

Revision:
3:672d4bd8225d
Parent:
2:89f04cd3bf45
Child:
4:64746224ab6e
--- a/explorer/explorer.h	Mon Apr 20 08:31:02 2020 +0000
+++ b/explorer/explorer.h	Tue Apr 21 12:31:27 2020 +0000
@@ -1,124 +1,63 @@
+/** explorer 
+* @the explorer file 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
+*/
 #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,
-};
+enum explorer_sprite{Move_right,Move_left,Stand_left, Stand_right};
+//we have four sprite form so we can define the sprite on the screen by using these enum
 //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;
+enum Player_direction {right,left};
 
-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();
+ Explorer();
  //Constructor
- ~explorer();
+ ~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);
+void set_x_coordinate(float joy_x, int speed, Player_direction direction);
+void set_y_coordinate(bool ifjump, int jump_height, int level);
 int get_y();
  
 int get_x();
 
-int get_m_counter();
-
-int get_j_counter();
+int get_speed();
 
-bool get_f_flag();
+int get_jump_height();
 
-bool get_r_flag();
-
-Respond_value get_respond_value
 Player_direction get_direction();
 
-int * get_respond(Respond_value respond);
+explorer_sprite get_explorer_sprite();
+
+int * get_form(explorer_sprite sprite);
+//this function is used to get the players form and print on the screen (same as the item file)
 
 void fall(bool f_flag, Gamepad &gamepad);
+//the fall flag need to add music to hint the player that the game is over
+void reset_flag(bool reset_flag,Gamepad &gamepad);
+//the reset flag also need to add music to hint the player that the game has been reseted
+bool get_fall_flag();
+
+bool get_reset_flag();
  
  private:
-  void change_x(float joystick_x);
     
   int _x;
   int _y;
-  int _move_counter;
+  int _speed;
   int _level;
-  int _jump_counter;
+  int _jump_height;
   bool _f_flag;
   bool _r_flag;
   Player_direction _player_direction;
-  Respond_value _respond_value;   
+  explorer_sprite _sprite   
 };
 #endif