Massive copyright update. I'm sorry if I'm crediting Matze for something he didn...
[supertux.git] / src / object / player.hpp
index b247186..cc250cb 100644 (file)
@@ -1,7 +1,7 @@
 //  $Id$
 //
-//  SuperTux -  A Jump'n Run
-//  Copyright (C) 2003 Tobias Glaesser <tobi.web@gmx.de>
+//  SuperTux
+//  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
 //
 //  This program is free software; you can redistribute it and/or
 //  modify it under the terms of the GNU General Public License
@@ -16,6 +16,7 @@
 //  You should have received a copy of the GNU General Public License
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
 #ifndef SUPERTUX_PLAYER_H
 #define SUPERTUX_PLAYER_H
 
 #include "control/controller.hpp"
 #include "scripting/player.hpp"
 #include "player_status.hpp"
+#include "display_effect.hpp"
+#include "script_interface.hpp"
+#include "console.hpp"
+#include "coin.hpp"
 
 class BadGuy;
 class Portable;
@@ -76,7 +81,21 @@ extern TuxBodyParts* big_tux;
 extern TuxBodyParts* fire_tux;
 extern TuxBodyParts* ice_tux;
 
-class Player : public MovingObject, public Scripting::Player
+class FallingCoin : public GameObject
+{
+public:
+  FallingCoin(const Vector& start_position, const int x_vel);
+  ~FallingCoin();
+
+  void draw(DrawingContext& context);
+  void update(float elapsed_time);
+private:
+  Vector  pos;
+  Sprite* sprite;
+  Physic  physic;
+};
+
+class Player : public MovingObject, public Scripting::Player, public ScriptInterface
 {
 public:
   enum HurtMode { KILL, SHRINK };
@@ -91,8 +110,8 @@ private:
   bool dying;
   bool backflipping;
   int  backflip_direction;
+  
 public:
-
   Direction dir;
   Direction old_dir;
 
@@ -103,7 +122,7 @@ public:
   bool jumping;
   bool can_jump;
   bool butt_jump;
-  
+
   Timer invincible_timer;
   Timer skidding_timer;
   Timer safe_timer;
@@ -119,6 +138,9 @@ public:
   Player(PlayerStatus* player_status);
   virtual ~Player();
 
+  virtual void expose(HSQUIRRELVM vm, int table_idx);
+  virtual void unexpose(HSQUIRRELVM vm, int table_idx);
+
   void set_controller(Controller* controller);  
 
   virtual void update(float elapsed_time);
@@ -139,6 +161,9 @@ public:
   void kill(HurtMode mode);
   void check_bounds(Camera* camera);
   void move(const Vector& vector);
+
+  virtual void set_bonus(const std::string& bonus);
+  virtual void add_coins(int count);
   void set_bonus(BonusType type, bool animate = false);
   PlayerStatus* get_status()
   {
@@ -147,15 +172,24 @@ public:
   // set kick animation
   void kick();
 
+  /**
+   * Adds velocity to the player (be carefull when using this)
+   */
+  void add_velocity(const Vector& velocity);
+
   void bounce(BadGuy& badguy);
 
   bool is_dead() const
   { return dead; }
   bool is_big();
-  
+
+  void set_visible(bool visible);
+  bool get_visible();
+
+  bool on_ground();
+
 private:
   void handle_input();
-  bool on_ground();
   bool deactivated;
   
   void init();
@@ -167,11 +201,16 @@ private:
   void deactivate();
   void walk(float speed);
 
+  bool visible;
+
+  float adjust_height;
+
   Portable* grabbed_object;
 
   Sprite* smalltux_gameover;
   Sprite* smalltux_star;
   Sprite* bigtux_star;
+  Vector floor_normal;
 };
 
 #endif /*SUPERTUX_PLAYER_H*/