-Worldmap cleanups (use DrawingContext transformstack)
[supertux.git] / src / object / player.h
index be6398c..0fe60fa 100644 (file)
 #ifndef SUPERTUX_PLAYER_H
 #define SUPERTUX_PLAYER_H
 
-#include "SDL.h"
+#include <vector>
+#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 "defines.h"
+#include "player_status.h"
 
 using namespace SuperTux;
 
 class BadGuy;
+class Portable;
 
 /* Times: */
 
@@ -40,18 +43,6 @@ class BadGuy;
 #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! */
 
-/* Scores: */
-
-#define SCORE_BRICK 5
-#define SCORE_DISTRO 20
-
-/* Sizes: */
-
-#define SMALL 0
-#define BIG 1
-
-#include <vector>
-
 struct PlayerKeymap
 {
 public:
@@ -67,31 +58,33 @@ public:
 
 extern PlayerKeymap keymap;
 
-struct player_input_type
+/** 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
 {
-  int right;
-  int left;
-  int up;
-  int old_up;
-  int down;
-  int fire;
-  int old_fire;
-  int activate;
-  int jump;
-  int old_jump;
+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;
 };
 
-void player_input_init(player_input_type* pplayer_input);
-
 class Camera;
 class PlayerStatus;
 
 extern Surface* tux_life;
 
-extern Sprite* smalltux_gameover;
-extern Sprite* smalltux_star;
-extern Sprite* bigtux_star;
-
 #define GROWING_TIME 1.0
 #define GROWING_FRAMES 7
 extern Surface* growingtux_left[GROWING_FRAMES];
@@ -130,16 +123,16 @@ class Player : public MovingObject
 {
 public:
   enum HurtMode { KILL, SHRINK };
-  enum Power { NONE_POWER, FIRE_POWER, ICE_POWER };
   enum FallMode { ON_GROUND, JUMPING, TRAMPOLINE_JUMP, FALLING };
 
-  player_input_type  input;
-  int got_power;
-  int size;
+  PlayerInputType input;
+  PlayerStatus* player_status;
   bool duck;
-  bool holding_something;
   bool dead;
-  DyingType dying;
+
+private:
+  bool dying;
+public:
 
   Direction dir;
   Direction old_dir;
@@ -162,7 +155,7 @@ public:
   int flaps_nb;
 
   // temporary to help player's choosing a flapping
-  enum { MAREK_FLAP, RICARDO_FLAP, RYAN_FLAP, NONE_FLAP };
+  enum { MAREK_FLAP, RICARDO_FLAP, RYAN_FLAP, NO_FLAP };
   int flapping_mode;
 
   Timer2 invincible_timer;
@@ -177,15 +170,11 @@ public:
   Physic physic;
   
 public:
-  Player();
+  Player(PlayerStatus* player_status);
   virtual ~Player();
   
-  int  key_event(SDLKey key, int state);
-  void level_begin();
+  bool key_event(SDLKey key, bool state);
   void handle_input();
-  void grabdistros();
-
-  PlayerStatus& get_status();
 
   virtual void action(float elapsed_time);
   virtual void draw(DrawingContext& context);
@@ -194,31 +183,42 @@ public:
   void make_invincible();
   bool is_invincible() const
   {
-      return invincible_timer.started();
+    return invincible_timer.started();
   }
+  bool is_dying() const
+  {
+    return dying;
+  }
+  
   void kill(HurtMode mode);
   void player_remove_powerups();
   void check_bounds(Camera* camera);
-  bool on_ground();
-  bool under_solid();
-  void grow(bool animate = false);
   void move(const Vector& vector);
+  void set_bonus(BonusType type, bool animate = false);
+  PlayerStatus* get_status()
+  {
+    return player_status;
+  }
 
   void bounce(BadGuy& badguy);
 
   bool is_dead() const
   { return dead; }
+  bool is_big();
   
 private:
+  bool on_ground();
+  
   void init();
   
   void handle_horizontal_input();
   void handle_vertical_input();
-  void remove_powerups();
+
+  Portable* grabbed_object;
+
+  Sprite* smalltux_gameover;
+  Sprite* smalltux_star;
+  Sprite* bigtux_star;
 };
 
 #endif /*SUPERTUX_PLAYER_H*/
-
-/* Local Variables: */
-/* mode:c++ */
-/* End: */