mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-05 10:59:48 +00:00
starting ti implement IController.hpp
This commit is contained in:
@@ -49,6 +49,7 @@ set(HEADERS
|
||||
include/Drawables/3D/Ray.hpp
|
||||
include/Drawables/3D/Sphere.hpp
|
||||
include/Drawables/3D/Triangle.hpp
|
||||
include/Controllers/IController.hpp
|
||||
)
|
||||
|
||||
set(SRC
|
||||
|
||||
@@ -10,11 +10,13 @@
|
||||
|
||||
#include <raylib.h>
|
||||
#include <vector>
|
||||
#include "IController.hpp"
|
||||
|
||||
namespace RAY {
|
||||
namespace RAY
|
||||
{
|
||||
|
||||
//! @brief Entity representing a gamepad controller
|
||||
class GamePad {
|
||||
class GamePad : public IController {
|
||||
public:
|
||||
typedef ::GamepadButton Button;
|
||||
|
||||
@@ -23,7 +25,7 @@ namespace RAY {
|
||||
GamePad(int id);
|
||||
|
||||
//! @brief A default destructor
|
||||
~GamePad() = default;
|
||||
~GamePad() = override default;
|
||||
|
||||
//! @brief A default copy constructor
|
||||
GamePad(const GamePad &) = default;
|
||||
@@ -34,29 +36,29 @@ namespace RAY {
|
||||
|
||||
//! @brief Returns true if Button is pressed on the gamepad
|
||||
//! @param Button The keycode of the button
|
||||
bool isPressed(Button);
|
||||
bool isPressed(Button) override;
|
||||
|
||||
//! @brief Returns true if Button is down on the gamepad
|
||||
//! @param Button The keycode of the button
|
||||
bool isDown(Button);
|
||||
bool isDown(Button) override;
|
||||
|
||||
//! @brief Returns true if Button is released on the gamepad
|
||||
//! @param Button The keycode of the button
|
||||
bool isReleased(Button);
|
||||
bool isReleased(Button) override;
|
||||
|
||||
//! @brief Returns true if Button is up on the gamepad
|
||||
//! @param Button The keycode of the button
|
||||
bool isUp(Button);
|
||||
bool isUp(Button) override;
|
||||
|
||||
//! @brief Returns true if controller is available
|
||||
bool isAvailable(Button);
|
||||
bool isAvailable(Button) override;
|
||||
|
||||
//! @brief Sets gamepad's id
|
||||
void setID(int id);
|
||||
|
||||
//! @brief Fetch currently pressed buttons
|
||||
//! @return Returns a vector containing keycode of currently pressed buttons
|
||||
std::vector<GamePad::Button> getPressedButtons(void);
|
||||
std::vector<GamePad::Button> getPressedButtons(void) override;
|
||||
|
||||
private:
|
||||
//! @brief The id of the controller, used to fetch buttons' states
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Created by cbihan on 17/05/2021.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace RAY
|
||||
{
|
||||
class IController
|
||||
{
|
||||
public:
|
||||
//! @brief Returns true if Button is pressed on the gamepad
|
||||
//! @param Button The keycode of the button
|
||||
virtual bool isPressed(Button) = 0;
|
||||
|
||||
//! @brief Returns true if Button is down on the gamepad
|
||||
//! @param Button The keycode of the button
|
||||
virtual bool isDown(Button) = 0;
|
||||
|
||||
//! @brief Returns true if Button is released on the gamepad
|
||||
//! @param Button The keycode of the button
|
||||
virtual bool isReleased(Button) = 0;
|
||||
|
||||
//! @brief Returns true if Button is up on the gamepad
|
||||
//! @param Button The keycode of the button
|
||||
virtual bool isUp(Button) = 0;
|
||||
|
||||
//! @brief Returns true if controller is available
|
||||
virtual bool isAvailable(Button) = 0;
|
||||
|
||||
//! @brief Fetch currently pressed buttons
|
||||
//! @return Returns a vector containing keycode of currently pressed buttons
|
||||
virtual std::vector<GamePad::Button> getPressedButtons(void) = 0;
|
||||
|
||||
virtual ~IController() = default;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user