17 #ifndef HEADER_SUPERTUX_OBJECT_PLAYER_HPP 18 #define HEADER_SUPERTUX_OBJECT_PLAYER_HPP 20 #include "scripting/player.hpp" 21 #include "sprite/sprite_ptr.hpp" 22 #include "squirrel/exposed_object.hpp" 23 #include "supertux/direction.hpp" 24 #include "supertux/moving_object.hpp" 25 #include "supertux/physic.hpp" 26 #include "supertux/player_status.hpp" 27 #include "supertux/sequence.hpp" 28 #include "supertux/timer.hpp" 29 #include "video/surface_ptr.hpp" 37 extern const float TUX_INVINCIBLE_TIME_WARNING;
43 enum FallMode { ON_GROUND, JUMPING, TRAMPOLINE_JUMP, FALLING };
49 virtual void update(
float dt_sec)
override;
57 void set_controller(
const Controller* controller);
60 bool is_winning()
const {
return m_winning; }
63 void set_speedlimit(
float newlimit);
64 float get_speedlimit()
const;
66 const Controller& get_controller()
const {
return *m_controller; }
68 void use_scripting_controller(
bool use_or_release);
69 void do_scripting_controller(
const std::string& control,
bool pressed);
71 void make_invincible();
73 bool is_invincible()
const {
return m_invincible_timer.started(); }
74 bool is_dying()
const {
return m_dying; }
76 Direction peeking_direction_x()
const {
return m_peekingX; }
77 Direction peeking_direction_y()
const {
return m_peekingY; }
79 void kill(
bool completely);
80 void move(
const Vector& vector);
82 bool add_bonus(
const std::string& bonus);
83 bool set_bonus(
const std::string& bonus);
84 void add_coins(
int count);
85 int get_coins()
const;
91 bool add_bonus(BonusType type,
bool animate =
false);
94 bool set_bonus(BonusType type,
bool animate =
false);
96 PlayerStatus& get_status()
const {
return m_player_status; }
130 void bounce(
BadGuy& badguy);
132 bool is_dead()
const {
return m_dead; }
134 bool is_stone()
const {
return m_stone; }
136 void set_visible(
bool visible);
137 bool get_visible()
const;
139 bool on_ground()
const;
141 Portable* get_grabbed_object()
const {
return m_grabbed_object; }
142 void stop_grabbing() { m_grabbed_object =
nullptr; }
146 bool has_grabbed(
const std::string& object_name)
const;
179 Physic& get_physic() {
return m_physic; }
184 void walk(
float speed);
185 void set_dir(
bool right);
186 void stop_backflipping();
188 void position_grabbed_object();
193 void handle_input_ghost();
194 void handle_input_climbing();
196 void handle_horizontal_input();
197 void handle_vertical_input();
200 void early_jump_apex();
202 bool slightly_above_ground()
const;
204 BonusType string_to_bonus(
const std::string& bonus)
const;
207 void apply_friction();
215 std::unique_ptr<CodeController> m_scripting_controller;
222 int m_backflip_direction;
223 Direction m_peekingX;
224 Direction m_peekingY;
225 float m_ability_time;
230 bool m_jump_early_apex;
232 bool m_ice_this_frame;
233 SpritePtr m_lightsprite;
234 SpritePtr m_powersprite;
243 float m_last_ground_y;
244 FallMode m_fall_mode;
247 bool m_on_ground_flag;
250 Timer m_jump_button_timer;
251 bool m_wants_buttjump;
254 bool m_does_buttjump;
255 Timer m_invincible_timer;
258 Timer m_skidding_timer;
261 Timer m_shooting_timer;
262 Timer m_ability_timer;
263 Timer m_cooldown_timer;
269 Timer m_second_growup_sound_timer;
271 Timer m_backflip_timer;
281 SurfacePtr m_airarrow;
288 Timer m_unduck_hurt_timer;
291 unsigned int m_idle_stage;
void do_duck()
duck down if possible.
Definition: player.cpp:593
This class keeps player status between different game sessions (for example when switching maps in th...
Definition: player_status.hpp:38
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:31
Definition: controller.hpp:56
void do_cheer()
play cheer animation.
Definition: player.cpp:585
void set_edit_mode(bool enable)
Switches edit mode on/off.
Definition: player.cpp:1656
void add_velocity(const Vector &velocity)
Adds velocity to the player (be careful when using this)
Definition: player.cpp:1561
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: player.cpp:1162
Simple two dimensional vector.
Definition: vector.hpp:24
Physics engine.
Definition: physic.hpp:27
bool adjust_height(float new_height)
Changes height of bounding box.
Definition: player.cpp:264
This class binds a certain GameObject class to a scripting class.
Definition: exposed_object.hpp:45
Vector get_velocity() const
Returns the current velocity of the player.
Definition: player.cpp:1580
Definition: sequence.hpp:33
void start_climbing(Climbable &climbable)
Requests that the player start climbing the given Climbable.
Definition: player.cpp:1662
virtual bool is_singleton() const override
If true only a single object of this type is allowed in a given GameObjectManager.
Definition: player.hpp:55
An object that inherits from this object is considered "portable" and can be carried around by the pl...
Definition: portable.hpp:29
virtual void update(float dt_sec) override
This function is called once per frame and allows the object to update it's state.
Definition: player.cpp:300
virtual bool is_saveable() const override
Indicates if the object will be saved.
Definition: player.hpp:54
bool has_grabbed(const std::string &object_name) const
Checks whether the player has grabbed a certain object.
Definition: player.cpp:1750
void do_backflip()
do a backflip if possible.
Definition: player.cpp:642
virtual void collision_solid(const CollisionHit &hit) override
this function is called when the object collided with something solid
Definition: player.cpp:1353
Definition: climbable.hpp:28
void do_standup()
stand back up if possible.
Definition: player.cpp:616
Base class for all the things that make up Levels' Sectors.
Definition: game_object.hpp:46
virtual HitResponse collision(GameObject &other, const CollisionHit &hit) override
this function is called when the object collided with any other object
Definition: player.cpp:1398
Base class for all dynamic/moving game objects.
Definition: moving_object.hpp:31
This is a dummy controller that doesn't react to any user input but should be controlled by code...
Definition: codecontroller.hpp:24
void do_jump(float yspeed)
jump in the air if possible sensible values for yspeed are negative - unless we want to jump into the...
Definition: player.cpp:656
void set_winning()
Level solved.
Definition: player.cpp:234
void trigger_sequence(const std::string &sequence_name, const SequenceData *data=nullptr)
Orders the current GameSession to start a sequence.
Definition: player.cpp:286
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
void set_ghost_mode(bool enable)
Switches ghost mode on/off.
Definition: player.cpp:1630
void stop_climbing(Climbable &climbable)
Requests that the player stop climbing the given Climbable.
Definition: player.cpp:1677
void kick()
set kick animation
Definition: player.cpp:1156
Definition: player.hpp:39
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
This class collects data about a collision.
Definition: collision_hit.hpp:44
bool get_ghost_mode() const
Returns whether ghost mode is currently enabled.
Definition: player.hpp:157
virtual void collision_tile(uint32_t tile_attributes) override
called when tiles with special attributes have been touched
Definition: player.cpp:1325