#include "sprite/sprite.hpp"
#include "physic.hpp"
#include "control/controller.hpp"
-#include "player_status.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;
static const float TUX_SAFE_TIME = 1.8;
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 TUX_FLAPPING_STRENGTH = 100; /* How much Y velocity Tux gains when flapping */
-static const float TUX_FLAPPING_LEAST_X = 30; /* How much X velocity Tux gains when flapping from vertical jump */
static const float GROWING_TIME = 1.0;
static const int GROWING_FRAMES = 7;
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 };
private:
bool dying;
+ bool backflipping;
+ int backflip_direction;
+
public:
-
Direction dir;
Direction old_dir;
bool on_ground_flag;
bool jumping;
- bool flapping;
bool can_jump;
- bool can_flap;
- bool falling_from_flap;
- bool enable_hover;
bool butt_jump;
-
- float flapping_velocity;
-
- // Ricardo's flapping
- int flaps_nb;
-
- // temporary to help player's choosing a flapping
- // TODO: remove this after agreeing on flapstyle!
- enum { MAREK_FLAP, RICARDO_FLAP, RYAN_FLAP, NO_FLAP };
- int flapping_mode;
Timer invincible_timer;
Timer skidding_timer;
Timer dying_timer;
Timer growing_timer;
Timer idle_timer;
- Timer flapping_timer;
+ Timer backflip_timer;
Physic physic;
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);
virtual void draw(DrawingContext& context);
virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
+ virtual void collision_tile(uint32_t tile_attributes);
void make_invincible();
bool is_invincible() const
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()
{
return player_status;
}
+ // 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();
void handle_horizontal_input();
void handle_vertical_input();
+ void activate();
+ 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*/