X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;ds=inline;f=src%2Fobject%2Fplayer.h;h=2d4364c59253349ea715054573d4046f44cb389d;hb=864c93e01ec366f730b3ebad08d5c52d6a9363b6;hp=0fe60fad3e26a46b28cb1d57c5dbbe16407ce2d7;hpb=495f8b77cb935fe8eff81bec755efca8e34e8a99;p=supertux.git diff --git a/src/object/player.h b/src/object/player.h index 0fe60fad3..2d4364c59 100644 --- a/src/object/player.h +++ b/src/object/player.h @@ -20,73 +20,32 @@ #define SUPERTUX_PLAYER_H #include -#include +#include "SDL.h" #include "timer.h" #include "direction.h" #include "video/surface.h" -#include "special/moving_object.h" -#include "special/sprite.h" -#include "math/physic.h" +#include "moving_object.h" +#include "sprite/sprite.h" +#include "physic.h" +#include "control/controller.h" #include "player_status.h" -using namespace SuperTux; - class BadGuy; class Portable; /* Times: */ - -#define TUX_SAFE_TIME 1.250 -#define TUX_INVINCIBLE_TIME 10.0 -#define TUX_INVINCIBLE_TIME_WARNING 2.0 -#define TUX_FLAPPING_TIME 1 /* How long Tux can flap his wings to gain additional jump height */ -#define TIME_WARNING 20 /* When to alert player they're low on time! */ - -struct PlayerKeymap -{ -public: - int jump; - int up; - int down; - int left; - int right; - int power; - - PlayerKeymap(); -}; - -extern PlayerKeymap keymap; - -/** Contains a field of booleans that indicate wheter a button is pressed or - * released. The old_ fields contain the state of the button at the previous - * frame. - */ -struct PlayerInputType -{ -public: - PlayerInputType(); - void reset(); - - bool left; - bool right; - bool up; - bool old_up; - bool down; - bool fire; - bool old_fire; - bool activate; - bool jump; - bool old_jump; -}; +static const float TUX_SAFE_TIME = 1.250; +static const float TUX_INVINCIBLE_TIME = 10.0; +static const float TUX_INVINCIBLE_TIME_WARNING = 2.0; +static const float TUX_FLAPPING_TIME = 1; /* How long Tux can flap his wings to gain additional jump height */ +static const float TIME_WARNING = 20; /* When to alert player they're low on time! */ +static const float GROWING_TIME = 1.0; +static const int GROWING_FRAMES = 7; class Camera; class PlayerStatus; -extern Surface* tux_life; - -#define GROWING_TIME 1.0 -#define GROWING_FRAMES 7 extern Surface* growingtux_left[GROWING_FRAMES]; extern Surface* growingtux_right[GROWING_FRAMES]; @@ -125,7 +84,7 @@ public: enum HurtMode { KILL, SHRINK }; enum FallMode { ON_GROUND, JUMPING, TRAMPOLINE_JUMP, FALLING }; - PlayerInputType input; + Controller* controller; PlayerStatus* player_status; bool duck; bool dead; @@ -158,23 +117,22 @@ public: enum { MAREK_FLAP, RICARDO_FLAP, RYAN_FLAP, NO_FLAP }; int flapping_mode; - Timer2 invincible_timer; - Timer2 skidding_timer; - Timer2 safe_timer; - Timer2 kick_timer; - Timer2 shooting_timer; // used to show the arm when Tux is shooting - Timer2 dying_timer; - Timer2 growing_timer; - Timer2 idle_timer; - Timer2 flapping_timer; + Timer invincible_timer; + Timer skidding_timer; + Timer safe_timer; + Timer kick_timer; + Timer shooting_timer; // used to show the arm when Tux is shooting + Timer dying_timer; + Timer growing_timer; + Timer idle_timer; + Timer flapping_timer; Physic physic; public: Player(PlayerStatus* player_status); virtual ~Player(); - - bool key_event(SDLKey key, bool state); - void handle_input(); + + void set_controller(Controller* controller); virtual void action(float elapsed_time); virtual void draw(DrawingContext& context); @@ -191,7 +149,6 @@ public: } void kill(HurtMode mode); - void player_remove_powerups(); void check_bounds(Camera* camera); void move(const Vector& vector); void set_bonus(BonusType type, bool animate = false); @@ -207,6 +164,7 @@ public: bool is_big(); private: + void handle_input(); bool on_ground(); void init();