supertux
Public Types | Public Member Functions | Public Attributes | List of all members
Player Class Referencefinal
Inheritance diagram for Player:
MovingObject ExposedObject< Player, scripting::Player > GameObject CollisionListener ScriptInterface

Public Types

enum  FallMode { ON_GROUND, JUMPING, TRAMPOLINE_JUMP, FALLING }
 

Public Member Functions

 Player (PlayerStatus &player_status, const std::string &name)
 
virtual void update (float dt_sec) override
 This function is called once per frame and allows the object to update it's state. More...
 
virtual void draw (DrawingContext &context) override
 The GameObject should draw itself onto the provided DrawingContext if this function is called. More...
 
virtual void collision_solid (const CollisionHit &hit) override
 this function is called when the object collided with something solid
 
virtual HitResponse collision (GameObject &other, const CollisionHit &hit) override
 this function is called when the object collided with any other object
 
virtual void collision_tile (uint32_t tile_attributes) override
 called when tiles with special attributes have been touched
 
virtual bool is_saveable () const override
 Indicates if the object will be saved. More...
 
virtual bool is_singleton () const override
 If true only a single object of this type is allowed in a given GameObjectManager.
 
void set_controller (const Controller *controller)
 
void set_winning ()
 Level solved. More...
 
bool is_winning () const
 
void set_speedlimit (float newlimit)
 
float get_speedlimit () const
 
const Controllerget_controller () const
 
void use_scripting_controller (bool use_or_release)
 
void do_scripting_controller (const std::string &control, bool pressed)
 
void make_invincible ()
 
bool is_invincible () const
 
bool is_dying () const
 
Direction peeking_direction_x () const
 
Direction peeking_direction_y () const
 
void kill (bool completely)
 
void move (const Vector &vector)
 
bool add_bonus (const std::string &bonus)
 
bool set_bonus (const std::string &bonus)
 
void add_coins (int count)
 
int get_coins () const
 
bool add_bonus (BonusType type, bool animate=false)
 picks up a bonus, taking care not to pick up lesser bonus items than we already have More...
 
bool set_bonus (BonusType type, bool animate=false)
 like add_bonus, but can also downgrade the bonus items carried
 
PlayerStatusget_status () const
 
void kick ()
 set kick animation
 
void do_cheer ()
 play cheer animation. More...
 
void do_duck ()
 duck down if possible. More...
 
void do_standup ()
 stand back up if possible. More...
 
void do_backflip ()
 do a backflip if possible. More...
 
void do_jump (float yspeed)
 jump in the air if possible sensible values for yspeed are negative - unless we want to jump into the ground of course
 
void add_velocity (const Vector &velocity)
 Adds velocity to the player (be careful when using this)
 
void add_velocity (const Vector &velocity, const Vector &end_speed)
 Adds velocity to the player until given end speed is reached.
 
Vector get_velocity () const
 Returns the current velocity of the player.
 
void bounce (BadGuy &badguy)
 
bool is_dead () const
 
bool is_big () const
 
bool is_stone () const
 
void set_visible (bool visible)
 
bool get_visible () const
 
bool on_ground () const
 
Portableget_grabbed_object () const
 
void stop_grabbing ()
 
bool has_grabbed (const std::string &object_name) const
 Checks whether the player has grabbed a certain object. More...
 
void set_ghost_mode (bool enable)
 Switches ghost mode on/off. More...
 
void set_edit_mode (bool enable)
 Switches edit mode on/off. More...
 
bool get_ghost_mode () const
 Returns whether ghost mode is currently enabled.
 
bool adjust_height (float new_height)
 Changes height of bounding box. More...
 
void trigger_sequence (const std::string &sequence_name, const SequenceData *data=nullptr)
 Orders the current GameSession to start a sequence. More...
 
void trigger_sequence (Sequence seq, const SequenceData *data=nullptr)
 Orders the current GameSession to start a sequence. More...
 
void start_climbing (Climbable &climbable)
 Requests that the player start climbing the given Climbable.
 
void stop_climbing (Climbable &climbable)
 Requests that the player stop climbing the given Climbable.
 
Physicget_physic ()
 
void activate ()
 
void deactivate ()
 
void walk (float speed)
 
void set_dir (bool right)
 
void stop_backflipping ()
 
void position_grabbed_object ()
 
void try_grab ()
 
- Public Member Functions inherited from MovingObject
 MovingObject (const ReaderMapping &reader)
 
virtual bool collides (GameObject &, const CollisionHit &) const override
 when 2 objects collided, we will first call the pre_collision_check functions of both objects that can decide on how to react to the collision. More...
 
virtual void set_pos (const Vector &pos)
 
virtual void move_to (const Vector &pos)
 
virtual bool listener_is_valid () const override
 
Vector get_pos () const
 
const Rectfget_bbox () const
 
const Vectorget_movement () const
 
CollisionGroup get_group () const
 
CollisionObjectget_collision_object ()
 
const CollisionObjectget_collision_object () const
 
virtual std::string get_class () const override
 
virtual ObjectSettings get_settings () override
 
virtual void editor_select () override
 The user clicked on the object in the editor and selected it.
 
- Public Member Functions inherited from GameObject
 GameObject (const std::string &name)
 
 GameObject (const ReaderMapping &reader)
 
virtual void finish_construction ()
 Called after all objects have been added to the Sector and the Sector is fully constructed. More...
 
UID get_uid () const
 
void save (Writer &writer)
 This function saves the object. More...
 
virtual std::string get_display_name () const
 
virtual bool has_variable_size () const
 Does this object have variable size (secret area trigger, wind, etc.)
 
virtual bool has_settings () const
 Indicates if get_settings() is implemented. More...
 
virtual void after_editor_set ()
 
bool is_valid () const
 returns true if the object is not scheduled to be removed yet
 
void remove_me ()
 schedules this object to be removed at the end of the frame
 
void add_remove_listener (ObjectRemoveListener *listener)
 registers a remove listener which will be called if the object gets removed/destroyed
 
void del_remove_listener (ObjectRemoveListener *listener)
 unregisters a remove listener, so it will no longer be called if the object gets removed/destroyed
 
void set_name (const std::string &name)
 
const std::string & get_name () const
 
virtual const std::string get_icon_path () const
 
virtual void stop_looping_sounds ()
 stops all looping sounds
 
virtual void play_looping_sounds ()
 continues all looping sounds
 
template<typename T >
T * get_component ()
 
void add_component (std::unique_ptr< GameObjectComponent > component)
 
void remove_component (GameObjectComponent *component)
 
virtual void editor_delete ()
 The editor requested the deletion of the object.
 
virtual void editor_deselect ()
 The object got deselected.
 
virtual void editor_update ()
 Called each frame in the editor, used to keep linked objects together (e.g. More...
 
- Public Member Functions inherited from ExposedObject< Player, scripting::Player >
 ExposedObject (Player *parent)
 Constructor. More...
 
virtual void expose (HSQUIRRELVM vm, SQInteger table_idx) override
 Exposes the parent GameObject to the script Interface. More...
 
virtual void unexpose (HSQUIRRELVM vm, SQInteger table_idx) override
 Un-exposes the parent GameObject to the script Interface. More...
 

Public Attributes

Direction m_dir
 
float m_last_ground_y
 
FallMode m_fall_mode
 
bool m_does_buttjump
 
Timer m_invincible_timer
 
Timer m_dying_timer
 

Additional Inherited Members

- Protected Member Functions inherited from MovingObject
void set_group (CollisionGroup group)
 
- Protected Attributes inherited from MovingObject
CollisionObject m_col
 
- Protected Attributes inherited from GameObject
std::string m_name
 a name for the gameobject, this is mostly a hint for scripts and for debugging, don't rely on names being set or being unique
 

Member Function Documentation

§ add_bonus()

bool Player::add_bonus ( BonusType  type,
bool  animate = false 
)

picks up a bonus, taking care not to pick up lesser bonus items than we already have

Returns
true if the bonus has been set (or was already good enough) false if the bonus could not be set (for example no space for big tux)

§ adjust_height()

bool Player::adjust_height ( float  new_height)

Changes height of bounding box.

Returns true if successful, false otherwise

§ do_backflip()

void Player::do_backflip ( )

do a backflip if possible.

§ do_cheer()

void Player::do_cheer ( )

play cheer animation.

This might need some space and behave in an unpredictable way. Best to use this at level end.

§ do_duck()

void Player::do_duck ( )

duck down if possible.

this won't last long as long as input is enabled.

§ do_standup()

void Player::do_standup ( )

stand back up if possible.

§ draw()

void Player::draw ( DrawingContext context)
overridevirtual

The GameObject should draw itself onto the provided DrawingContext if this function is called.

Implements GameObject.

§ has_grabbed()

bool Player::has_grabbed ( const std::string &  object_name) const

Checks whether the player has grabbed a certain object.

Parameters
nameName of the object to check

§ is_saveable()

virtual bool Player::is_saveable ( ) const
inlineoverridevirtual

Indicates if the object will be saved.

If false, the object will be skipped on saving and can't be cloned in the editor.

Reimplemented from GameObject.

§ set_edit_mode()

void Player::set_edit_mode ( bool  enable)

Switches edit mode on/off.

In edit mode, Tux will enter ghost_mode instead of dying.

§ set_ghost_mode()

void Player::set_ghost_mode ( bool  enable)

Switches ghost mode on/off.

Lets Tux float around and through solid objects.

§ set_winning()

void Player::set_winning ( )

Level solved.

Don't kill Tux any more.

§ trigger_sequence() [1/2]

void Player::trigger_sequence ( const std::string &  sequence_name,
const SequenceData data = nullptr 
)

Orders the current GameSession to start a sequence.

Parameters
sequence_nameName of the sequence to start
dataCustom additional sequence data

§ trigger_sequence() [2/2]

void Player::trigger_sequence ( Sequence  seq,
const SequenceData data = nullptr 
)

Orders the current GameSession to start a sequence.

Parameters
sequenceSequence to start
dataCustom additional sequence data

§ update()

void Player::update ( float  dt_sec)
overridevirtual

This function is called once per frame and allows the object to update it's state.

The dt_sec is the time that has passed since the last frame in seconds and should be the base for all timed calculations (don't use SDL_GetTicks directly as this will fail in pause mode). This function is not called in the Editor.

Implements GameObject.


The documentation for this class was generated from the following files: