SuperTuxKart
Public Types | Public Member Functions | Private Attributes | List of all members
KartControl Class Reference

Public Types

enum  SkidControl { SC_NONE, SC_NO_DIRECTION, SC_LEFT, SC_RIGHT }
 The skidding control state: SC_NONE: not pressed; SC_NO_DIRECTION: pressed, but no steering; SC_LEFT/RIGHT: pressed in the specified direction. More...
 

Public Member Functions

void setSteer (float f)
 Sets the current steering value. More...
 
void setAccel (float f)
 Sets the acceleration. More...
 
void setBrake (bool b)
 Sets if the kart is braking. More...
 
void setNitro (bool b)
 Sets if the kart activates nitro. More...
 
void setSkidControl (SkidControl sc)
 Sets the skid control for this kart. More...
 
void setRescue (bool b)
 Returns if this kart wants to get rescued. More...
 
void setFire (bool b)
 Sets if the kart wants to fire. More...
 
void setLookBack (bool b)
 Sets if the kart wants to look (and therefore also fires) backwards. More...
 
void reset ()
 Resets all controls. More...
 
bool operator== (const KartControl &other)
 Tests if two KartControls are equal.
 
void saveState (BareNetworkString *buffer) const
 Copies the important data from this objects into a memory buffer. More...
 
void rewindTo (BareNetworkString *buffer)
 Restores this object from a previously saved memory buffer. More...
 
char getButtonsCompressed () const
 Compresses all buttons into a single byte. More...
 
void setButtonsCompressed (char c)
 Sets the buttons from a compressed (1 byte) representation. More...
 
float getSteer () const
 Returns the current steering value in [-1, 1]. More...
 
float getAccel () const
 Returns current acceleration in [0, 1]. More...
 
bool getBrake () const
 Returns if the kart is braking. More...
 
bool getNitro () const
 Returns if the kart activates nitro. More...
 
SkidControl getSkidControl () const
 Returns the skidding control state: SC_NONE: not pressed; SC_NO_DIRECTION: pressed, but no steering; SC_LEFT/RIGHT: pressed in the specified direction. More...
 
bool getRescue () const
 Returns true if the kart triggered rescue. More...
 
bool getFire () const
 Returns if fire is selected. More...
 
bool getLookBack () const
 Returns if the kart wants to look back (which also implies that it will fire backwards. More...
 

Private Attributes

int16_t m_steer
 The current steering value in [-32767, 32767]. More...
 
uint16_t m_accel
 Acceleration, in [0, 65535]. More...
 
bool m_brake
 True if the kart brakes. More...
 
bool m_nitro
 True if the kart activates nitro. More...
 
SkidControl m_skid
 Skidding control state. More...
 
bool m_rescue
 True if rescue is selected. More...
 
bool m_fire
 True if fire is selected. More...
 
bool m_look_back
 True if the kart looks (and shoots) backwards. More...
 

Member Enumeration Documentation

◆ SkidControl

The skidding control state: SC_NONE: not pressed; SC_NO_DIRECTION: pressed, but no steering; SC_LEFT/RIGHT: pressed in the specified direction.

Member Function Documentation

◆ getAccel()

float KartControl::getAccel ( ) const
inline

Returns current acceleration in [0, 1].

◆ getBrake()

bool KartControl::getBrake ( ) const
inline

Returns if the kart is braking.

◆ getButtonsCompressed()

char KartControl::getButtonsCompressed ( ) const
inline

Compresses all buttons into a single byte.

◆ getFire()

bool KartControl::getFire ( ) const
inline

Returns if fire is selected.

◆ getLookBack()

bool KartControl::getLookBack ( ) const
inline

Returns if the kart wants to look back (which also implies that it will fire backwards.

◆ getNitro()

bool KartControl::getNitro ( ) const
inline

Returns if the kart activates nitro.

◆ getRescue()

bool KartControl::getRescue ( ) const
inline

Returns true if the kart triggered rescue.

◆ getSkidControl()

SkidControl KartControl::getSkidControl ( ) const
inline

Returns the skidding control state: SC_NONE: not pressed; SC_NO_DIRECTION: pressed, but no steering; SC_LEFT/RIGHT: pressed in the specified direction.

◆ getSteer()

float KartControl::getSteer ( ) const
inline

Returns the current steering value in [-1, 1].

◆ reset()

void KartControl::reset ( )
inline

Resets all controls.

◆ rewindTo()

void KartControl::rewindTo ( BareNetworkString buffer)

Restores this object from a previously saved memory buffer.

◆ saveState()

void KartControl::saveState ( BareNetworkString buffer) const

Copies the important data from this objects into a memory buffer.

◆ setAccel()

void KartControl::setAccel ( float  f)

Sets the acceleration.

◆ setBrake()

void KartControl::setBrake ( bool  b)

Sets if the kart is braking.

◆ setButtonsCompressed()

void KartControl::setButtonsCompressed ( char  c)
inline

Sets the buttons from a compressed (1 byte) representation.

/param c Character containing the compressed representation.

◆ setFire()

void KartControl::setFire ( bool  b)

Sets if the kart wants to fire.

◆ setLookBack()

void KartControl::setLookBack ( bool  b)

Sets if the kart wants to look (and therefore also fires) backwards.

◆ setNitro()

void KartControl::setNitro ( bool  b)

Sets if the kart activates nitro.

◆ setRescue()

void KartControl::setRescue ( bool  b)

Returns if this kart wants to get rescued.

◆ setSkidControl()

void KartControl::setSkidControl ( SkidControl  sc)

Sets the skid control for this kart.

◆ setSteer()

void KartControl::setSteer ( float  f)

Sets the current steering value.

Member Data Documentation

◆ m_accel

uint16_t KartControl::m_accel
private

Acceleration, in [0, 65535].

◆ m_brake

bool KartControl::m_brake
private

True if the kart brakes.

◆ m_fire

bool KartControl::m_fire
private

True if fire is selected.

◆ m_look_back

bool KartControl::m_look_back
private

True if the kart looks (and shoots) backwards.

◆ m_nitro

bool KartControl::m_nitro
private

True if the kart activates nitro.

◆ m_rescue

bool KartControl::m_rescue
private

True if rescue is selected.

◆ m_skid

SkidControl KartControl::m_skid
private

Skidding control state.

◆ m_steer

int16_t KartControl::m_steer
private

The current steering value in [-32767, 32767].


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