|
The Game Engine
1
|
Interface for player-world interaction. More...
#include <Player.h>
Collaboration diagram for Player:Public Types | |
| enum | InputAction { Accept, Deny, OpenMenu, Esc, Move, MoveUp, MoveDown, MoveLeft, MoveRight, Cursor, CursorUp, CursorDown, CursorLeft, CursorRight, Action, HotKey1, HotKey2, HotKey3, HotKey4, HotKey5, HotKey6, HotKey7, HotKey8, HotKey9, HotKey10, HotKey11, HotKey12, LBump, RBump, LTrigger, RTrigger } |
| This should be a list of all things that would usually appear in a game as settable to some hotkey. More... | |
Public Member Functions | |
| Player (string filename) | |
| Player (map< InputAction, vector< SDLKey >> keyMaps) | |
| Player (map< InputAction, vector< JoyStick >> joyMaps, map< InputAction, vector< JoyButton >> buttonMaps, int moveJoy=0) | |
| void | Control (WorldObject *wo) |
| Adds an object to list of controlled objects. More... | |
| void | RemoveControl (WorldObject *wo) |
| Removes Player control over a given Object. More... | |
| void | RemoveControl (string woName) |
| Removes Player control over a given Object with given name. More... | |
| WorldObject * | getObject (string name) |
| Get a pointer to the WorldObject with the specified name. More... | |
| WorldObject * | getObject (unsigned int index) |
| Get a pointer to the WorldObject in the specified position of the players WorldObject vector. More... | |
| vector< WorldObject * > | getObjects () |
| Get a vector of all WorldObject pointers belonging to the player. More... | |
| vector< WorldObject * > | getObjects (string name, int count=-1) |
| Get a vector of WorldObject pointers with given name. More... | |
| Point2D | getAveragePosition () |
| Calculate the average position of the player's WorldObjects. More... | |
| Point2D | getAveragePosition (string name) |
| Get the position of the player's WorldObject with the specified name. More... | |
| Point2D | getAveragePosition (vector< int > indices) |
| Calculate the position of the player using the WorldObjects specified by the vector of indices. More... | |
| Point2D | getAveragePosition (vector< string > names) |
| Calculate the position of the player using the WorldObjects with the names included in the vector. More... | |
| void | setPosition (double x, double y) |
| Set the position of all objects unde the control of the Player using the average position of the objects. More... | |
| void | setPosition (Point2D pos) |
| Set the position of all objects unde the control of the Player using the average position of the objects. More... | |
| void | move (double dx, double dy) |
| Move by given relative amount (doing collision) More... | |
| void | move (Point2D direction) |
| Moves the Player relative to the current pos (doing collision). More... | |
| void | moveTowards (Point2D point) |
| Moves the Player towards the given point (Path finding). More... | |
| void | setTransparency (float f) |
| Sets the transparency of the player by setting the transparency of all of the player's WorldObjects. More... | |
| void | changeTransparency (float df) |
| Sets the relative transparency of the player by setting the transparency of all of the player's WorldObjects. More... | |
| void | addKeyDownCallback (void(*fn)(SDLKey, SDLMod)) |
| Add a keyboard button down callback. More... | |
| void | removeKeyDownCallback (void(*fn)(SDLKey, SDLMod)) |
| remove a keyboard button down callback More... | |
| void | addKeyUpCallback (void(*fn)(SDLKey, SDLMod)) |
| Add a keyboard button down callback. More... | |
| void | removeKeyUpCallback (void(*fn)(SDLKey, SDLMod)) |
| remove a keyboard button down callback More... | |
| void | addMouseDownCallback (void(*fn)(Uint8, Input::MouseState)) |
| Add a keyboard button down callback. More... | |
| void | removeMouseDownCallback (void(*fn)(Uint8, Input::MouseState)) |
| remove a keyboard button down callback More... | |
| void | addMouseUpCallback (void(*fn)(Uint8, Input::MouseState)) |
| Add a keyboard button down callback. More... | |
| void | removeMouseUpCallback (void(*fn)(Uint8, Input::MouseState)) |
| remove a keyboard button down callback More... | |
| void | addMouseMoveCallback (void(*fn)(Input::MouseState)) |
| Add a keyboard button down callback. More... | |
| void | removeMouseMoveCallback (void(*fn)(Input::MouseState)) |
| remove a keyboard button down callback More... | |
| void | addJoyButtonDownCallback (void(*fn)(Uint8, JoyButton)) |
| Add a keyboard button down callback. More... | |
| void | removeJoyButtonDownCallback (void(*fn)(Uint8, JoyButton)) |
| remove a keyboard button down callback More... | |
| void | addJoyButtonUpCallback (void(*fn)(Uint8, JoyButton)) |
| Add a keyboard button down callback. More... | |
| void | removeJoyButtonUpCallback (void(*fn)(Uint8, JoyButton)) |
| remove a keyboard button down callback More... | |
| void | addJoyMoveCallback (void(*fn)(Uint8, JoyStick, Point2D)) |
| Add a keyboard button down callback. More... | |
| void | removeJoyMoveCallback (void(*fn)(Uint8, JoyStick, Point2D)) |
| remove a keyboard button down callback More... | |
| Point2D | getMovement (InputAction act=Move) |
| Obtain the movement Value from this input. More... | |
| bool | pressed (InputAction act) |
| Whether a key is pressed on this input. More... | |
| bool | triggered (InputAction act, int ms=-1) |
| Whether a key is triggered. More... | |
| bool | doubleTapped (InputAction act, int ms=-1) |
| Whether a key is double tapped. More... | |
Static Public Member Functions | |
| static bool | getAllPressed (InputAction act) |
| Check all inputs for values of act being down. More... | |
| static bool | getAllTriggered (InputAction act, int ms=-1) |
| Check all inputs for values for act being triggered (down then up) More... | |
| static Point2D | getAllMovement (InputAction act=Move) |
| Check all inputs for values of movement. More... | |
Protected Attributes | |
| vector< WorldObject * > | mObjects |
| The list of objects we control. More... | |
| Input * | mInput |
| Input device we are getting input from. More... | |
| map< InputAction, vector < SDLKey > > | mKeyMaps |
| map from InputAction to actual keyboard input More... | |
| map< InputAction, vector < JoyButton > > | mJoyButtonMaps |
| map from InputAction to joystick buttons More... | |
| map< InputAction, vector < JoyStick > > | mJoyStickMaps |
| map from InputAction to joystick buttons More... | |
| bool | useJoystick |
| Whether or not to use the Joystick for input. More... | |
Interface for player-world interaction.
This class is tasked with the following:
| enum Player::InputAction |
This should be a list of all things that would usually appear in a game as settable to some hotkey.
| Player::Player | ( | string | filename | ) |
Definition at line 4 of file Player.cpp.
Here is the call graph for this function:| Player::Player | ( | map< InputAction, vector< SDLKey >> | keyMaps | ) |
Definition at line 124 of file Player.cpp.
| Player::Player | ( | map< InputAction, vector< JoyStick >> | joyMaps, |
| map< InputAction, vector< JoyButton >> | buttonMaps, | ||
| int | moveJoy = 0 |
||
| ) |
Definition at line 129 of file Player.cpp.
| void Player::addJoyButtonDownCallback | ( | void(*)(Uint8, JoyButton) | fn | ) |
Add a keyboard button down callback.
| fn | The function to add |
| void Player::addJoyButtonUpCallback | ( | void(*)(Uint8, JoyButton) | fn | ) |
Add a keyboard button down callback.
| fn | The function to add |
Add a keyboard button down callback.
| fn | The function to add |
| void Player::addKeyDownCallback | ( | void(*)(SDLKey, SDLMod) | fn | ) |
Add a keyboard button down callback.
| fn | The function to add |
| void Player::addKeyUpCallback | ( | void(*)(SDLKey, SDLMod) | fn | ) |
Add a keyboard button down callback.
| fn | The function to add |
| void Player::addMouseDownCallback | ( | void(*)(Uint8, Input::MouseState) | fn | ) |
Add a keyboard button down callback.
| fn | The function to add |
| void Player::addMouseMoveCallback | ( | void(*)(Input::MouseState) | fn | ) |
Add a keyboard button down callback.
| fn | The function to add |
| void Player::addMouseUpCallback | ( | void(*)(Uint8, Input::MouseState) | fn | ) |
Add a keyboard button down callback.
| fn | The function to add |
| void Player::changeTransparency | ( | float | df | ) |
Sets the relative transparency of the player by setting the transparency of all of the player's WorldObjects.
| df | The amount to change the Player's transparency |
Definition at line 286 of file Player.cpp.
| void Player::Control | ( | WorldObject * | wo | ) |
Adds an object to list of controlled objects.
| wo | World object to put under player's control |
Definition at line 135 of file Player.cpp.
Here is the caller graph for this function:| bool Player::doubleTapped | ( | Player::InputAction | act, |
| int | ms = -1 |
||
| ) |
Whether a key is double tapped.
| act | The action to determine |
| ms | This value is an optional value that checks against the given ms instead of TRIGGERTIME (this value cannot be larger than 2^31) |
Definition at line 346 of file Player.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Check all inputs for values of movement.
Definition at line 317 of file Player.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Check all inputs for values of act being down.
| act | The action to be pressed |
Definition at line 295 of file Player.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Check all inputs for values for act being triggered (down then up)
| ms | This value is an optional value that checks against the given ms instead of TRIGGERTIME |
| act | Action to be triggered |
Definition at line 306 of file Player.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| Point2D Player::getAveragePosition | ( | ) |
Calculate the average position of the player's WorldObjects.
Definition at line 190 of file Player.cpp.
Here is the caller graph for this function:| Point2D Player::getAveragePosition | ( | string | name | ) |
Get the position of the player's WorldObject with the specified name.
| name | Name of the WorldObject that the position will be defined by. |
Definition at line 201 of file Player.cpp.
Here is the call graph for this function:| Point2D Player::getAveragePosition | ( | vector< int > | indices | ) |
Calculate the position of the player using the WorldObjects specified by the vector of indices.
| indices | List of WorldObject positions in the players vector of WorldObjects that specifies which WorldObjects to include when calculating the player position. |
Definition at line 208 of file Player.cpp.
| Point2D Player::getAveragePosition | ( | vector< string > | names | ) |
Calculate the position of the player using the WorldObjects with the names included in the vector.
| names | List of WorldObject names for objects that will be used when calculating the player position. |
Definition at line 219 of file Player.cpp.
Here is the call graph for this function:| Point2D Player::getMovement | ( | Player::InputAction | act = Move | ) |
Obtain the movement Value from this input.
| act | The action/Joystick to obtain movement data for |
Definition at line 365 of file Player.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| WorldObject * Player::getObject | ( | string | name | ) |
Get a pointer to the WorldObject with the specified name.
| name | Name of the desired WorldObject. |
Definition at line 155 of file Player.cpp.
Here is the caller graph for this function:| WorldObject * Player::getObject | ( | unsigned int | index | ) |
Get a pointer to the WorldObject in the specified position of the players WorldObject vector.
| index | Position of the desired WorldObject. |
Definition at line 166 of file Player.cpp.
| vector< WorldObject * > Player::getObjects | ( | ) |
Get a vector of all WorldObject pointers belonging to the player.
Definition at line 171 of file Player.cpp.
Here is the caller graph for this function:| vector< WorldObject * > Player::getObjects | ( | string | name, |
| int | count = -1 |
||
| ) |
Get a vector of WorldObject pointers with given name.
If count is specified, then it will return at most that many pointers.
| name | Name of the WorldObject desired by the user. |
| count | Maximum number of pointers to retrieve. |
Definition at line 176 of file Player.cpp.
| void Player::move | ( | double | dx, |
| double | dy | ||
| ) |
Move by given relative amount (doing collision)
| dx | Amount to move x |
| dy | Amount to move y |
Definition at line 257 of file Player.cpp.
Here is the caller graph for this function:| void Player::move | ( | Point2D | direction | ) |
Moves the Player relative to the current pos (doing collision).
| direction | Direction to move the Player |
Definition at line 264 of file Player.cpp.
| void Player::moveTowards | ( | Point2D | point | ) |
Moves the Player towards the given point (Path finding).
| point | Point to move the Player towards. |
Definition at line 271 of file Player.cpp.
| bool Player::pressed | ( | InputAction | act | ) |
Whether a key is pressed on this input.
| act | The action to determine |
Definition at line 387 of file Player.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| void Player::RemoveControl | ( | WorldObject * | wo | ) |
Removes Player control over a given Object.
| wo | Object to stop controlling |
Definition at line 139 of file Player.cpp.
| void Player::RemoveControl | ( | string | woName | ) |
Removes Player control over a given Object with given name.
| woName | Object to stop controlling |
Definition at line 147 of file Player.cpp.
| void Player::removeJoyButtonDownCallback | ( | void(*)(Uint8, JoyButton) | fn | ) |
remove a keyboard button down callback
| fn | The function to add |
| void Player::removeJoyButtonUpCallback | ( | void(*)(Uint8, JoyButton) | fn | ) |
remove a keyboard button down callback
| fn | The function to add |
remove a keyboard button down callback
| fn | The function to add |
| void Player::removeKeyDownCallback | ( | void(*)(SDLKey, SDLMod) | fn | ) |
remove a keyboard button down callback
| fn | The function to add |
| void Player::removeKeyUpCallback | ( | void(*)(SDLKey, SDLMod) | fn | ) |
remove a keyboard button down callback
| fn | The function to add |
| void Player::removeMouseDownCallback | ( | void(*)(Uint8, Input::MouseState) | fn | ) |
remove a keyboard button down callback
| fn | The function to add |
| void Player::removeMouseMoveCallback | ( | void(*)(Input::MouseState) | fn | ) |
remove a keyboard button down callback
| fn | The function to add |
| void Player::removeMouseUpCallback | ( | void(*)(Uint8, Input::MouseState) | fn | ) |
remove a keyboard button down callback
| fn | The function to add |
| void Player::setPosition | ( | double | x, |
| double | y | ||
| ) |
Set the position of all objects unde the control of the Player using the average position of the objects.
| x | New x position of the centroid of the player. |
| y | New y position of the centroid of the player. |
Definition at line 235 of file Player.cpp.
Here is the call graph for this function:| void Player::setPosition | ( | Point2D | pos | ) |
Set the position of all objects unde the control of the Player using the average position of the objects.
| pos | New position for the centroid of the player. |
Definition at line 246 of file Player.cpp.
Here is the call graph for this function:| void Player::setTransparency | ( | float | f | ) |
Sets the transparency of the player by setting the transparency of all of the player's WorldObjects.
| f | The WorldObject's transparency [0,1] other values will be force set |
Definition at line 279 of file Player.cpp.
| bool Player::triggered | ( | Player::InputAction | act, |
| int | ms = -1 |
||
| ) |
Whether a key is triggered.
| act | The action to determine |
| ms | This value is an optional value that checks against the given ms instead of TRIGGERTIME (this value cannot be larger than 2^31) |
Definition at line 328 of file Player.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |