Annchienta::InputManager Class Reference

List of all members.

Public Member Functions

bool buttonDown (int code) const
bool buttonTicked (int code) const
bool cancelKeyTicked () const
bool clicked (int x1, int y1, int x2, int y2) const
int getCancelKey () const
PersongetInputControlledPerson () const
InputMode getInputMode () const
int getInteractKey () const
Point getMousePoint () const
int getMouseX () const
int getMouseY () const
bool hover (int x1, int y1, int x2, int y2) const
 InputManager ()
bool interactKeyTicked () const
bool isMouseMoved () const
bool isRunning ()
bool keyDown (int code) const
bool keyTicked (int code) const
void setCancelKey (int code)
void setInputControlledPerson (Person *person)
void setInputMode (InputMode mode)
void setInteractKey (int code)
void setMouseVisibility (bool value) const
void stop ()
void update ()
 ~InputManager ()

Private Attributes

int cancelKey
PersoninputControlledPerson
InputMode inputMode
int interactKey
Uint8 * keyState
bool mouseMoved
Uint8 mouseState
int mouseX
int mouseY
bool running
bool supportMouse
bool tickedButtons [2]
bool tickedKeys [SDLK_LAST]


Detailed Description

Used to handle input tasks. Remember to call update() every frame.

Constructor & Destructor Documentation

Annchienta::InputManager::InputManager (  ) 

Annchienta::InputManager::~InputManager (  ) 


Member Function Documentation

bool Annchienta::InputManager::buttonDown ( int  code  )  const

Parameters:
code 0 for left mouse button, 1 for right mouse button.
Returns:
Is the given button currently down?

bool Annchienta::InputManager::buttonTicked ( int  code  )  const

Parameters:
code 0 for left mouse button, 1 for right mouse button.
Returns:
Is the given button ticked? (See keyTicked())

bool Annchienta::InputManager::cancelKeyTicked (  )  const

Returns:
Quick check for cancel key.

bool Annchienta::InputManager::clicked ( int  x1,
int  y1,
int  x2,
int  y2 
) const

Checks if a certain area is clicked.

Returns:
Was this area clicked since the last update()?

int Annchienta::InputManager::getCancelKey (  )  const

Returns:
The cancel key. See Annchienta keyCodes.

Person* Annchienta::InputManager::getInputControlledPerson (  )  const

Returns:
Obtain the Person controlled by the user.

InputMode Annchienta::InputManager::getInputMode (  )  const

Returns:
See InputMode.

int Annchienta::InputManager::getInteractKey (  )  const

Returns:
The interact key. See Annchienta keyCodes.

Point Annchienta::InputManager::getMousePoint (  )  const

Returns:
A Point indicating mouse coordinates.

int Annchienta::InputManager::getMouseX (  )  const

Returns:
Mouse X.

int Annchienta::InputManager::getMouseY (  )  const

Returns:
Mouse Y.

bool Annchienta::InputManager::hover ( int  x1,
int  y1,
int  x2,
int  y2 
) const

Checks if the mouse is in a given rectangle.

Parameters:
x1 Left X of that rectangle.
y1 Top Y of that rectangle.
x2 Right X of that rectangle.
y2 Bottom Y of that rectangle.
Returns:
Is the mouse in that area?

bool Annchienta::InputManager::interactKeyTicked (  )  const

Returns:
Quick check for interact key.

bool Annchienta::InputManager::isMouseMoved (  )  const

Returns:
Is the mouse moved since the last update?

bool Annchienta::InputManager::isRunning (  ) 

This function should be called if you want to know if the engine is still running. This function will return false if the user closed the window.

Returns:
Whether the engine is still running or not.

bool Annchienta::InputManager::keyDown ( int  code  )  const

Parameters:
code See Annchienta keyCodes.
Returns:
Is the given key pressed down?

bool Annchienta::InputManager::keyTicked ( int  code  )  const

This is a function like keyDown(), but slightly different: this function only returns true if the key was ticked since the last update. That means that, even when the user keeps pressing the key, this function will only return true the first time. Quite useful for menus and things like that.

Parameters:
code See Annchienta keyCodes.
Returns:
Is the given key ticked?

void Annchienta::InputManager::setCancelKey ( int  code  ) 

Set the default cancel key.

Parameters:
code See Annchienta keyCodes.

void Annchienta::InputManager::setInputControlledPerson ( Person person  ) 

Sets the Person controlled by input. If there already is one, the previous setting will be overwritten.

Parameters:
person The Person to be controlled by the user.

void Annchienta::InputManager::setInputMode ( InputMode  mode  ) 

Parameters:
mode See InputMode.

void Annchienta::InputManager::setInteractKey ( int  code  ) 

Sets the default interact key.

Parameters:
code See Annchienta keyCodes.

void Annchienta::InputManager::setMouseVisibility ( bool  value  )  const

Parameters:
value Whether the mouse should be visible or not.

void Annchienta::InputManager::stop (  ) 

Stops the game. running() will return false from now on.

void Annchienta::InputManager::update (  ) 

Updates all keys to their current state.


Member Data Documentation

bool Annchienta::InputManager::tickedKeys[SDLK_LAST] [private]


Generated on Wed Feb 4 16:31:47 2009 for Annchienta by  doxygen 1.5.7.1