SuperTuxKart
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
RubberBand Class Reference

This class is used together with the pluger to display a rubber band from the shooting kart to the plunger. More...

#include <rubber_band.hpp>

Inheritance diagram for RubberBand:
Inheritance graph
[legend]

Public Types

enum  RubberBandTo { RB_TO_PLUNGER = 0 , RB_TO_KART , RB_TO_TRACK }
 

Public Member Functions

 RubberBand (Plunger *plunger, AbstractKart *kart)
 RubberBand constructor.
 
void reset ()
 
void updateGraphics (float dt)
 
void update (int ticks)
 Updates the rubber band.
 
void hit (AbstractKart *kart_hit, const Vec3 *track_xyz=NULL)
 The plunger hit a kart or the track.
 
uint8_t get8BitState () const
 
void set8BitState (uint8_t bit_state)
 
void remove ()
 

Private Member Functions

void checkForHit (const Vec3 &k, const Vec3 &p)
 Uses a raycast to see if anything has hit the rubber band.
 
void updatePosition ()
 Updates the position of the rubber band.
 

Private Attributes

Vec3 m_hit_position
 If rubber band is attached to track, the coordinates.
 
Plungerm_plunger
 The plunger the rubber band is attached to.
 
AbstractKartm_owner
 The kart who shot this plunger.
 
RubberBandTo m_attached_state
 
std::shared_ptr< SP::SPDynamicDrawCallm_dy_dc
 The dynamic draw call of the rubber band.
 
irr::scene::IMeshSceneNode * m_node
 
AbstractKartm_hit_kart
 The kart a plunger might have hit.
 
Vec3 m_end_position
 Stores the end of the rubber band (i.e.
 

Detailed Description

This class is used together with the pluger to display a rubber band from the shooting kart to the plunger.

Member Enumeration Documentation

◆ RubberBandTo

Enumerator
RB_TO_PLUNGER 

Rubber band is attached to plunger.


RB_TO_KART 

Rubber band is attached to a kart hit.

RB_TO_TRACK 

Rubber band is attached to track.


Constructor & Destructor Documentation

◆ RubberBand()

RubberBand::RubberBand ( Plunger plunger,
AbstractKart kart 
)

RubberBand constructor.

It creates a simple quad and attaches it to the root(!) of the graph. It's easier this way to get the right coordinates than attaching it to the plunger or kart, and trying to find the other coordinate.

Parameters
plungerPointer to the plunger (non const, since the rubber band can trigger an explosion)
kartReference to the kart.

Member Function Documentation

◆ checkForHit()

void RubberBand::checkForHit ( const Vec3 k,
const Vec3 p 
)
private

Uses a raycast to see if anything has hit the rubber band.

Parameters
kPosition of the kart = one end of the rubber band
pPosition of the plunger = other end of the rubber band.

◆ hit()

void RubberBand::hit ( AbstractKart kart_hit,
const Vec3 track_xyz = NULL 
)

The plunger hit a kart or the track.

Parameters
kart_hitThe kart hit, or NULL if the track was hit.
track_xyz The coordinated where the track was hit (NULL if a kart was hit.

◆ update()

void RubberBand::update ( int  ticks)

Updates the rubber band.

It takes the new position of the kart and the plunger, and sets the quad representing the rubber band appropriately. It then casts a ray along the rubber band to detect if anything is hit. If so, an explosion is triggered.

Parameters
dtTime step size.

◆ updatePosition()

void RubberBand::updatePosition ( )
private

Updates the position of the rubber band.

It especially sets the end position of the rubber band, i.e. the side attached to the plunger, track, or kart hit.

Member Data Documentation

◆ m_end_position

Vec3 RubberBand::m_end_position
private

Stores the end of the rubber band (i.e.

the side attached to the plunger.


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