SuperTuxKart
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Powerup Class Reference
Inheritance diagram for Powerup:
Inheritance graph
[legend]

Public Member Functions

 Powerup (AbstractKart *kart_)
 Constructor, stores the kart to which this powerup belongs.
 
 ~Powerup ()
 Frees the memory for the sound effects.
 
void set (PowerupManager::PowerupType _type, int n=1)
 Sets the collected items.
 
void setNum (int n=1)
 Sets the amount of the current collected item.
 
void reset ()
 Resets the powerup, called at begin of a race.
 
MaterialgetIcon () const
 Returns the icon for the currently collected powerup.
 
void adjustSound ()
 Does the sound configuration.
 
void use ()
 Use (fire) this powerup.
 
void hitBonusBox (const ItemState &item)
 This function is called when a bnous box is it.
 
void saveState (BareNetworkString *buffer) const
 Save the powerup state.
 
void rewindTo (BareNetworkString *buffer)
 Restore a powerup state.
 
void update (int ticks)
 
int getNum () const
 Returns the number of powerups.
 
PowerupManager::PowerupType getType () const
 Returns the type of this powerup.
 

Private Attributes

SFXBasem_sound_use
 Sound effect that is being played.
 
PowerupManager::PowerupType m_type
 The powerup type.
 
int m_number
 Number of collected powerups.
 
AbstractKartm_kart
 The owner (kart) of this powerup.
 
std::set< int > m_played_sound_ticks
 

Constructor & Destructor Documentation

◆ Powerup()

Powerup::Powerup ( AbstractKart kart)

Constructor, stores the kart to which this powerup belongs.

Parameters
kartThe kart to which this powerup belongs.

Member Function Documentation

◆ getIcon()

Material * Powerup::getIcon ( ) const

Returns the icon for the currently collected powerup.

Used in the race_gui to display the collected item.

◆ hitBonusBox()

void Powerup::hitBonusBox ( const ItemState item_state)

This function is called when a bnous box is it.

This function can be called on a server (in which case item and add_info are not used), or on a client, in which case the item and additional info is used to make sure server and clients are synched correctly.

Parameters
n
item_stateThe item_state (bonux box) that was hit. This is necessary for servers so that the clients can be informed which item was collected.

◆ rewindTo()

void Powerup::rewindTo ( BareNetworkString buffer)

Restore a powerup state.

Called from the kart rewinder when restoring a state.

Parameters
bufferBuffer with the state of this powerup object.

◆ saveState()

void Powerup::saveState ( BareNetworkString buffer) const

Save the powerup state.

Called from the kart rewinder when saving the kart state or when a new powerup even is saved.

Parameters
bufferThe buffer into which to save the state.

◆ set()

void Powerup::set ( PowerupManager::PowerupType  type,
int  n = 1 
)

Sets the collected items.

The number of items is increased if the same item is currently collected, otherwise replaces the existing item. It also sets item specific sounds.

Parameters
typeThew new type.
nNumber of items of the given type.

◆ setNum()

void Powerup::setNum ( int  n = 1)

Sets the amount of the current collected item.

Parameters
nNumber of items.

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