Bubba-3D  0.9.0
Awesome game engine!
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ControlStatus Class Reference

The class that contains information about a function at the state of creation. More...

#include <ControlStatus.h>

Public Types

enum  Activator {
  NONE = 1024, KEYBOARD = 256, MOUSE = 512, JOYSTICK_0 = 1,
  JOYSTICK_1 = 2, JOYSTICK_2 = 4, JOYSTICK_3 = 8, JOYSTICK_4 = 16,
  JOYSTICK_5 = 32, JOYSTICK_6 = 64, JOYSTICK_7 = 128, JOYSTICK = 255
}
 

Public Member Functions

Activator getMaxActivator ()
 
float getValue ()
 
float getValue (Activator activator)
 
bool isActive ()
 
bool isActive (Activator activator)
 
 ControlStatus (Activator activator, float value)
 
void addButton (Activator activator, float value)
 
void merge (ControlStatus cs)
 

Static Public Member Functions

static Activator activatorFromJoystickNumber (int n)
 

Detailed Description

The class that contains information about a function at the state of creation.

To read on how to make bindings check the documentation for ControlsManager.

Checking if a control after the bindings has been set is very simple. We will use the same bindings as given in the example in ControlsManager. The code will make sure that the vehicle does what the user wants.

//Global enum defined elsewhere (Same enum as when we made the bindings):
enum Controls : int {TURN,ACCELERATE,JUMP};
ControlStatus cs = cm->getStatus(ACCELERATE);
if(cs.isActive()){
//increase the speed of the vehicle
accelerateVehicle(cs->getValue()*maxAcceleration);
}
cs = cm->getStatus(TURN);
if(cs.isActive()){
turnVehicle(cs->getValue()*maxTurnSpeed);
}
if(cm->getStatus(JUMP).isActive()){
jump();
}

Definition at line 59 of file ControlStatus.h.

Constructor & Destructor Documentation

ControlStatus::ControlStatus ( Activator  activator,
float  value 
)

Creates a ControlStatus activated by activator with value value.

Definition at line 30 of file ControlStatus.cpp.

Member Function Documentation

ControlStatus::Activator ControlStatus::getMaxActivator ( )

Returns the activator that produced the result given by getValue() and isActive()

Definition at line 64 of file ControlStatus.cpp.

float ControlStatus::getValue ( )

Returns a number in the range [-100,100] for dual buttons. Returns a number in the range [0,100] for non-dual buttons. Returns the maximum value from any activator.

Definition at line 52 of file ControlStatus.cpp.

float ControlStatus::getValue ( Activator  activator)

Gets the value from the specified activator. Returns a number in the range [-100,100] for dual buttons. Returns a number in the range [0,100] for non-dual buttons.

Definition at line 70 of file ControlStatus.cpp.

bool ControlStatus::isActive ( Activator  activator)

Alias for: return abs(getValue(activator)) != 0;

Definition at line 80 of file ControlStatus.cpp.


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