HeadBall  1.0
A game
Public Member Functions | List of all members
HeadBall::InputManager Class Reference

Handle the input given by the user. More...

#include <InputManager.hpp>

Collaboration diagram for HeadBall::InputManager:
Collaboration graph

Public Member Functions

 InputManager ()
 Construct a new Input Manager object. More...
 
 ~InputManager ()
 Destroy the Input Manager object. More...
 
bool isSpriteClicked (sf::Sprite sprite, sf::Mouse::Button button, sf::RenderWindow &window)
 Check whether a sprite is clicked or not. More...
 
sf::Vector2i getMousePosition (sf::RenderWindow &window)
 Get the Mouse Position object. More...
 
bool isMoving (std::string direction, std::string player="p1")
 Check whether the player is moving or not. More...
 
bool isDoing (std::string action, std::string player="p1")
 Check whether the player is performing a certain action or not. More...
 

Detailed Description

Handle the input given by the user.

The class handles the input given by the user, whether it is the clicking of a button(sprite) or movement and action of the player in the main game.

Constructor & Destructor Documentation

◆ InputManager()

HeadBall::InputManager::InputManager ( )
inline

Construct a new Input Manager object.

◆ ~InputManager()

HeadBall::InputManager::~InputManager ( )
inline

Destroy the Input Manager object.

Member Function Documentation

◆ getMousePosition()

sf::Vector2i HeadBall::InputManager::getMousePosition ( sf::RenderWindow &  window)

Get the Mouse Position object.

Parameters
windowThe SFML render window object
Returns
sf::Vector2i The position of the mouse in with respect to the render window object

◆ isDoing()

bool HeadBall::InputManager::isDoing ( std::string  action,
std::string  player = "p1" 
)

Check whether the player is performing a certain action or not.

Parameters
actionThe action : "kick" or "jump"
playerThe player : "p1" or "p2"
Returns
true if the player is performing the action
false if the player is not performing the action

◆ isMoving()

bool HeadBall::InputManager::isMoving ( std::string  direction,
std::string  player = "p1" 
)

Check whether the player is moving or not.

Parameters
directionThe direction : "left" or "right"
playerThe player : "p1" or "p2"
Returns
true if the player is moving in certain direction
false if the player is not moving in certain direction

◆ isSpriteClicked()

bool HeadBall::InputManager::isSpriteClicked ( sf::Sprite  sprite,
sf::Mouse::Button  button,
sf::RenderWindow &  window 
)

Check whether a sprite is clicked or not.

Parameters
spriteSprite which is to be checked
buttonThe mouse button whose click is checked: left, right or middle
windowThe SFML render window object where the click is checked
Returns
true if the sprite is clicked
false if the sprite is not clicked

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