My Project
GraphicalLib.hpp
1 /*
2 ** EPITECH PROJECT, 2022
3 ** B-CPP-500-PAR-5-1-rtype-martin.vanaud
4 ** File description:
5 ** GraphicalLib
6 */
7 
8 #ifndef GRAPHICALLIB_HPP_
9  #define GRAPHICALLIB_HPP_
10 
11 
12 #include <map>
13 #include <cstring>
14 #include <memory>
15 #include <string>
16 #include "IGraphicalLib.hpp"
17 
22 namespace rtype {
27  class GraphicalLib : public IGraphicalLib {
28  public:
33  GraphicalLib();
38  ~GraphicalLib();
39 
48  void initWindow(const int screenWidth, const int screenHeight, std::string title, const int framerate) override;
49 
54  void closeWindow() override;
55 
60  void clearScreen() override;
65  void startDrawingWindow() override;
70  void endDrawingWindow() override;
71 
78  bool windowShouldClose() override;
79 
90  void 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) override;
102  bool checkMouseCollision(Position const &position, float const &x, float const &y, float const &height, float const &width) override;
109  bool IsLeftMouseButtonPressed() override;
116  bool IsLeftMouseButtonReleased() override;
122  Position getMousePosition() override;
129  Color createColor(std::array<float, 4> const &array) override;
138  void drawText(std::string const &text, Position const &pos, std::size_t const &fontSize, std::array<float, 4> const &color) override;
143  void initAudio() override;
148  void closeAudio() override;
154  void playASound(MySound &sound) override;
160  void playASoundMulti(MySound &sound) override;
166  void playAMusic(MyMusic &music) override;
172  void updateAMusic(MyMusic &music) override;
173 
174  float getMusicVolume(MyMusic &music) override;
175  void setMusicVolume(MyMusic &music, float volume) override;
176 
184  bool hasBeenPressed(int key) override;
192  bool isBeingPressed(int key) override;
200  bool hasBeenReleased(int key) override;
208  bool isNotBeingPressed(int key) override;
214  void setExitKey(int key) override;
220  int getPressedKeycode() override;
226  int getPressedCharcode() override;
227 
228 
229  protected:
230  private:
231 
232  };
233 
234 }
235 
236 #endif /* !GRAPHICALLIB_HPP_ */
Position
3 dimension Position class (x, y, z)
Definition: Position.hpp:19
rtype::GraphicalLib::getMousePosition
Position getMousePosition() override
Get the Mouse Position object.
Definition: GraphicalLib.cpp:68
rtype::GraphicalLib
GraphicalLib class.
Definition: GraphicalLib.hpp:27
rtype::GraphicalLib::setExitKey
void setExitKey(int key) override
Set the Exit Key object.
Definition: GraphicalLib.cpp:152
rtype::GraphicalLib::getPressedCharcode
int getPressedCharcode() override
Get the Pressed Charcode object.
Definition: GraphicalLib.cpp:162
rtype::GraphicalLib::playASound
void playASound(MySound &sound) override
A method to play a sound.
Definition: GraphicalLib.cpp:101
rtype::GraphicalLib::IsLeftMouseButtonPressed
bool IsLeftMouseButtonPressed() override
A method to check if the left mouse button is pressed.
Definition: GraphicalLib.cpp:58
rtype::GraphicalLib::checkMouseCollision
bool checkMouseCollision(Position const &position, float const &x, float const &y, float const &height, float const &width) override
A method to check a collison between the mouse and a rectangle.
Definition: GraphicalLib.cpp:53
rtype::GraphicalLib::IsLeftMouseButtonReleased
bool IsLeftMouseButtonReleased() override
A method to check if the left mouse button is released.
Definition: GraphicalLib.cpp:63
rtype::GraphicalLib::drawText
void drawText(std::string const &text, Position const &pos, std::size_t const &fontSize, std::array< float, 4 > const &color) override
A method to draw a text.
Definition: GraphicalLib.cpp:85
rtype::GraphicalLib::isBeingPressed
bool isBeingPressed(int key) override
Check if a key is being pressed.
Definition: GraphicalLib.cpp:137
rtype::GraphicalLib::hasBeenReleased
bool hasBeenReleased(int key) override
Check if a key has been released.
Definition: GraphicalLib.cpp:142
rtype::GraphicalLib::GraphicalLib
GraphicalLib()
Construct a new Graphical Lib object.
Definition: GraphicalLib.cpp:10
rtype::GraphicalLib::updateAMusic
void updateAMusic(MyMusic &music) override
A method to update the music.
Definition: GraphicalLib.cpp:116
rtype::GraphicalLib::startDrawingWindow
void startDrawingWindow() override
Start drawing in the window.
Definition: GraphicalLib.cpp:34
rtype::GraphicalLib::createColor
Color createColor(std::array< float, 4 > const &array) override
Create a Color object.
Definition: GraphicalLib.cpp:74
rtype::GraphicalLib::playAMusic
void playAMusic(MyMusic &music) override
A method to load a sound.
Definition: GraphicalLib.cpp:111
rtype::GraphicalLib::initWindow
void initWindow(const int screenWidth, const int screenHeight, std::string title, const int framerate) override
A method to initialize a window object.
Definition: GraphicalLib.cpp:18
MyTexture
MyTexture class.
Definition: MyTexture.hpp:19
rtype::GraphicalLib::isNotBeingPressed
bool isNotBeingPressed(int key) override
Check if a key is not being pressed.
Definition: GraphicalLib.cpp:147
MyMusic
Music class.
Definition: MyMusic.hpp:18
rtype::GraphicalLib::hasBeenPressed
bool hasBeenPressed(int key) override
Check if a key has been pressed.
Definition: GraphicalLib.cpp:132
rtype::GraphicalLib::getPressedKeycode
int getPressedKeycode() override
Get the Pressed Keycode object.
Definition: GraphicalLib.cpp:157
MySound
MySound class.
Definition: MySound.hpp:18
rtype
rtype namespace
Definition: GraphicalLib.hpp:22
rtype::GraphicalLib::drawSprite
void 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) override
A method to draw a sprite.
Definition: GraphicalLib.cpp:48
rtype::GraphicalLib::endDrawingWindow
void endDrawingWindow() override
Stop drawing in the window.
Definition: GraphicalLib.cpp:38
rtype::GraphicalLib::playASoundMulti
void playASoundMulti(MySound &sound) override
Play a sound with a multichannel buffer pool.
Definition: GraphicalLib.cpp:106
rtype::GraphicalLib::clearScreen
void clearScreen() override
Clear the window.
Definition: GraphicalLib.cpp:29
rtype::GraphicalLib::closeWindow
void closeWindow() override
A method to close a window.
Definition: GraphicalLib.cpp:24
rtype::IGraphicalLib
IGraphicalLib class.
Definition: IGraphicalLib.hpp:29
rtype::GraphicalLib::initAudio
void initAudio() override
A method to init the audio devide.
Definition: GraphicalLib.cpp:91
rtype::GraphicalLib::~GraphicalLib
~GraphicalLib()
Destroy the Graphical Lib object.
Definition: GraphicalLib.cpp:14
rtype::GraphicalLib::closeAudio
void closeAudio() override
A method to close the audio device.
Definition: GraphicalLib.cpp:96
rtype::GraphicalLib::windowShouldClose
bool windowShouldClose() override
Check if the window should close.
Definition: GraphicalLib.cpp:43