mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-07 03:25:10 +00:00
Controllers
This commit is contained in:
@@ -58,6 +58,15 @@ set(HEADERS
|
||||
set(SRC
|
||||
src/Color.cpp
|
||||
src/Font.cpp
|
||||
src/Model.cpp
|
||||
src/Window.cpp
|
||||
src/Audio/Music.cpp
|
||||
src/Audio/Sound.cpp
|
||||
src/Camera/Camera2D.cpp
|
||||
src/Camera/Camera3D.cpp
|
||||
src/Controllers/Gamepad.cpp
|
||||
src/Controllers/Keyboard.cpp
|
||||
src/Controllers/Mouse.cpp
|
||||
)
|
||||
|
||||
add_library(${LIB_NAME} STATIC ${SRC} ${HEADERS})
|
||||
|
||||
@@ -35,10 +35,6 @@ namespace RAY::Controller {
|
||||
|
||||
//! @return A 2D vector holding the current position of the cursor
|
||||
static Vector2 getCursorPosition(void);
|
||||
|
||||
//! @brief Fetch currently pressed buttons
|
||||
//! @return a vector containing keycode of currently pressed buttons
|
||||
static std::vector<Mouse::Button> getPressedButtons(void);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2021
|
||||
** Bomberman
|
||||
** File description:
|
||||
** Keyboard
|
||||
*/
|
||||
|
||||
#include "Controllers/Keyboard.hpp"
|
||||
|
||||
|
||||
bool RAY::Controller::Keyboard::isPressed(RAY::Controller::Keyboard::Key key)
|
||||
{
|
||||
return IsKeyPressed(key);
|
||||
}
|
||||
|
||||
bool RAY::Controller::Keyboard::isDown(RAY::Controller::Keyboard::Key key)
|
||||
{
|
||||
return IsKeyDown(key);
|
||||
}
|
||||
|
||||
bool RAY::Controller::Keyboard::isReleased(RAY::Controller::Keyboard::Key key)
|
||||
{
|
||||
return IsKeyReleased(key);
|
||||
}
|
||||
|
||||
bool RAY::Controller::Keyboard::isUp(RAY::Controller::Keyboard::Key key)
|
||||
{
|
||||
return IsKeyUp(key);
|
||||
}
|
||||
|
||||
std::vector<RAY::Controller::Keyboard::Key> RAY::Controller::Keyboard::getPressedKeys(void)
|
||||
{
|
||||
std::vector<RAY::Controller::Keyboard::Key> pressedKeys;
|
||||
|
||||
do {
|
||||
pressedKeys.push_back((RAY::Controller::Keyboard::Key)GetKeyPressed());
|
||||
} while (pressedKeys.back() != KEY_NULL);
|
||||
return pressedKeys;
|
||||
}
|
||||
|
||||
std::vector<char> RAY::Controller::Keyboard::getPressedChars(void)
|
||||
{
|
||||
std::vector<char> pressedChars;
|
||||
|
||||
do {
|
||||
pressedChars.push_back(GetCharPressed());
|
||||
} while (pressedChars.back() != '\0');
|
||||
return pressedChars;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2021
|
||||
** Bomberman
|
||||
** File description:
|
||||
** Mouse
|
||||
*/
|
||||
|
||||
#include "Controllers/Mouse.hpp"
|
||||
|
||||
bool RAY::Controller::Mouse::isPressed(RAY::Controller::Mouse::Button button)
|
||||
{
|
||||
return IsMouseButtonPressed(button);
|
||||
}
|
||||
|
||||
bool RAY::Controller::Mouse::isDown(RAY::Controller::Mouse::Button button)
|
||||
{
|
||||
return IsMouseButtonDown(button);
|
||||
}
|
||||
|
||||
bool RAY::Controller::Mouse::isReleased(RAY::Controller::Mouse::Button button)
|
||||
{
|
||||
return IsMouseButtonReleased(button);
|
||||
}
|
||||
|
||||
bool RAY::Controller::Mouse::isUp(RAY::Controller::Mouse::Button button)
|
||||
{
|
||||
return IsMouseButtonUp(button);
|
||||
}
|
||||
|
||||
Vector2 RAY::Controller::Mouse::getCursorPosition(void)
|
||||
{
|
||||
return GetMousePosition();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user