My Project
IGraphicalLib.hpp
1 /*
2 ** EPITECH PROJECT, 2022
3 ** B-CPP-500-PAR-5-1-rtype-martin.vanaud
4 ** File description:
5 ** IGraphicalLib
6 */
7 
8 #ifndef IGRAPHICALLIB_HPP_
9  #define IGRAPHICALLIB_HPP_
10 
11  #include <iostream>
12  #include <memory>
13  #include <utility>
14  #include <raylib.h>
15 
16  #include "MySound.hpp"
17  #include "MyMusic.hpp"
18  #include "MyTexture.hpp"
19  #include "Keyboard.hpp"
20  #include "Position.hpp"
21 
25 namespace rtype {
29  class IGraphicalLib {
30  public:
34  virtual ~IGraphicalLib() = default;
35 
44  virtual auto initWindow(const int screenWidth, const int screenHeight, std::string title, const int framerate) -> void = 0;
45 
49  virtual auto closeWindow() -> void = 0;
50 
55  virtual auto clearScreen() -> void = 0;
56 
60  virtual auto startDrawingWindow() -> void = 0;
61 
65  virtual auto endDrawingWindow() -> void = 0;
66 
73  virtual auto windowShouldClose() -> bool = 0;
74 
85  virtual auto drawSprite(MyTexture const &texture, std::array<float, 4> const &rectSource, std::array<float, 4> const &rectDest, std::pair<float, float> const &origin, float const &rotation, float const &scale) -> void = 0;
86 
98  virtual auto checkMouseCollision(Position const &position, float const &x, float const &y, float const &height, float const &width) -> bool = 0;
99 
106  virtual auto IsLeftMouseButtonPressed() -> bool = 0;
113  virtual auto IsLeftMouseButtonReleased() -> bool = 0;
114 
120  virtual auto getMousePosition() -> Position = 0;
129  virtual auto drawText(std::string const &text, Position const &pos, std::size_t const &fontSize, std::array<float, 4> const &color) -> void = 0;
136  virtual auto createColor(std::array<float, 4> const &array) -> Color = 0;
141  virtual auto initAudio() -> void = 0;
146  virtual auto closeAudio() -> void = 0;
152  virtual auto playASound(MySound &sound) -> void = 0;
158  virtual auto playASoundMulti(MySound &sound) -> void = 0;
164  virtual auto playAMusic(MyMusic &music) -> void = 0;
170  virtual auto updateAMusic(MyMusic &music) -> void = 0;
171 
172  virtual auto getMusicVolume(MyMusic &music) -> float = 0;
173  virtual auto setMusicVolume(MyMusic &music, float volume) -> void = 0;
174 
182  virtual auto hasBeenPressed(int key) -> bool = 0;
190  virtual auto isBeingPressed(int key) -> bool = 0;
198  virtual auto hasBeenReleased(int key) -> bool = 0;
206  virtual auto isNotBeingPressed(int key) -> bool = 0;
212  virtual auto setExitKey(int key) -> void = 0;
218  virtual auto getPressedKeycode() -> int = 0;
224  virtual auto getPressedCharcode() -> int = 0;
225 
226 
227  protected:
228  private:
229 
230  };
231 }
232 
233 #endif /* !IGRAPHICALLIB_HPP_ */
Position
3 dimension Position class (x, y, z)
Definition: Position.hpp:19
rtype::IGraphicalLib::playAMusic
virtual auto playAMusic(MyMusic &music) -> void=0
Play a music.
rtype::IGraphicalLib::isBeingPressed
virtual auto isBeingPressed(int key) -> bool=0
Check if a key is being pressed.
rtype::IGraphicalLib::closeAudio
virtual auto closeAudio() -> void=0
Close the audio device.
rtype::IGraphicalLib::setExitKey
virtual auto setExitKey(int key) -> void=0
Set the Exit Key object.
rtype::IGraphicalLib::endDrawingWindow
virtual auto endDrawingWindow() -> void=0
Stop drawing in the window.
rtype::IGraphicalLib::IsLeftMouseButtonPressed
virtual auto IsLeftMouseButtonPressed() -> bool=0
Check if the left mouse button is pressed.
rtype::IGraphicalLib::playASound
virtual auto playASound(MySound &sound) -> void=0
Play a sound.
rtype::IGraphicalLib::~IGraphicalLib
virtual ~IGraphicalLib()=default
Destroy the IGraphicalLib object.
rtype::IGraphicalLib::updateAMusic
virtual auto updateAMusic(MyMusic &music) -> void=0
Update the music.
rtype::IGraphicalLib::drawSprite
virtual auto drawSprite(MyTexture const &texture, std::array< float, 4 > const &rectSource, std::array< float, 4 > const &rectDest, std::pair< float, float > const &origin, float const &rotation, float const &scale) -> void=0
Draw a sprite.
rtype::IGraphicalLib::checkMouseCollision
virtual auto checkMouseCollision(Position const &position, float const &x, float const &y, float const &height, float const &width) -> bool=0
Check the mouse collision.
rtype::IGraphicalLib::windowShouldClose
virtual auto windowShouldClose() -> bool=0
Check if window should close.
rtype::IGraphicalLib::closeWindow
virtual auto closeWindow() -> void=0
A method to close the window.
rtype::IGraphicalLib::drawText
virtual auto drawText(std::string const &text, Position const &pos, std::size_t const &fontSize, std::array< float, 4 > const &color) -> void=0
Draw a text.
rtype::IGraphicalLib::getPressedKeycode
virtual auto getPressedKeycode() -> int=0
Get the Pressed Keycode object.
rtype::IGraphicalLib::getMousePosition
virtual auto getMousePosition() -> Position=0
Get the Mouse Position object.
rtype::IGraphicalLib::getPressedCharcode
virtual auto getPressedCharcode() -> int=0
Get the Pressed Charcode object.
rtype::IGraphicalLib::initWindow
virtual auto initWindow(const int screenWidth, const int screenHeight, std::string title, const int framerate) -> void=0
A method to initialize a window object.
rtype::IGraphicalLib::startDrawingWindow
virtual auto startDrawingWindow() -> void=0
Start drawing in the window.
MyTexture
MyTexture class.
Definition: MyTexture.hpp:19
rtype::IGraphicalLib::hasBeenPressed
virtual auto hasBeenPressed(int key) -> bool=0
Check if a key has been pressed.
rtype::IGraphicalLib::IsLeftMouseButtonReleased
virtual auto IsLeftMouseButtonReleased() -> bool=0
Check if the left mouse button is released.
rtype::IGraphicalLib::clearScreen
virtual auto clearScreen() -> void=0
A method to clear the window.
rtype::IGraphicalLib::isNotBeingPressed
virtual auto isNotBeingPressed(int key) -> bool=0
Check if a key is not being pressed.
rtype::IGraphicalLib::hasBeenReleased
virtual auto hasBeenReleased(int key) -> bool=0
Check if a key has been released.
MyMusic
Music class.
Definition: MyMusic.hpp:18
rtype::IGraphicalLib::initAudio
virtual auto initAudio() -> void=0
Init the audio device.
MySound
MySound class.
Definition: MySound.hpp:18
rtype
rtype namespace
Definition: GraphicalLib.hpp:22
rtype::IGraphicalLib::createColor
virtual auto createColor(std::array< float, 4 > const &array) -> Color=0
Create a Color object.
rtype::IGraphicalLib
IGraphicalLib class.
Definition: IGraphicalLib.hpp:29
rtype::IGraphicalLib::playASoundMulti
virtual auto playASoundMulti(MySound &sound) -> void=0
Play a sound with a multichannel buffer pool.