R-Type
RenderInterfaces.hpp
Go to the documentation of this file.
1 /*
2 ** EPITECH PROJECT, 2023
3 ** R-Type
4 ** File description:
5 ** RenderInterfaces
6 */
7 
8 #ifndef RENDERINTERFACES_HPP_
9 #define RENDERINTERFACES_HPP_
10 #include <string>
11 #include "utils/Vector.hpp"
12 
13 namespace GameEngine
14 {
17  template <class T>
18  class IFont
19  {
20  public:
22  ~IFont() = default;
25  virtual const T &getFont() const = 0;
28  virtual void load(const std::string &filename) = 0;
29  };
30 
33  template <typename T, template <typename> class M>
34  class IRect
35  {
36  public:
38  ~IRect() = default;
41  virtual const M<T> getBaseRect() const = 0;
42  };
43 
46  template <typename T>
47  class IClock
48  {
49  public:
51  ~IClock() = default;
54  virtual T &getClock() = 0;
55  };
56 
60  template <class T, template <typename> class rectT>
61  class ITexture
62  {
63  public:
65  ~ITexture() = default;
68  virtual const T &getTexture() const = 0;
72  virtual void load(const std::string &filename, const IRect<int, rectT> &area) = 0;
73  };
74 
77  template <typename MusicType>
78  class IMusic
79  {
80  public:
82  ~IMusic() = default;
85  virtual const MusicType &getMusic() const = 0;
88  virtual void load(const std::string &filename) = 0;
90  virtual void play() = 0;
91  };
92 
97  template <class T, class TextuT, template <typename> class rectT>
98  class ISprite
99  {
100  public:
102  ~ISprite() = default;
105  virtual const T &getSprite() const = 0;
109  virtual void load(const ITexture<TextuT, rectT> &texture, bool resetRect = false) = 0;
112  virtual void setPosition(const Vector2<float> position) = 0;
115  virtual void setTextureRect(const IRect<int, rectT> &newRect) = 0;
116  };
117 
120  template <class T>
121  class IEvent
122  {
123  public:
126  virtual T &getEvent() = 0;
127  };
128 
131  template <class T>
132  class IView
133  {
134  public:
136  ~IView() = default;
139  virtual const T &getBaseView() const = 0;
140  virtual void setCenter(const Vector2<float> &center) = 0;
141  virtual Vector2<float> getCenter() const = 0;
142  virtual void setViewPort(const Vector2<float> &startingPoint, float width, float height) = 0;
143  };
144 
150  template <class T, class Vt, class Et, class D>
151  class IWindow
152  {
153  public:
155  virtual ~IWindow() = default;
158  virtual const T &getWindow() const = 0;
161  virtual T &getWindow() = 0;
164  virtual void draw(const D &drawable) = 0;
167  virtual void setView(const IView<Vt> &view) = 0;
170  virtual void setFramerateLimit(const float rate) = 0;
173  virtual bool isOpen() const = 0;
177  virtual bool pollEvent(IEvent<Et> &event) = 0;
179  virtual void close() = 0;
181  virtual void display() = 0;
183  virtual void clear() = 0;
188  virtual void create(int width, int height, const std::string &title) = 0;
189 
190 #ifdef DEBUG
192  virtual void initDebug() = 0;
193  virtual void shutdownDebug() = 0;
194  virtual void drawDebug() = 0;
195 #endif
196  };
197 } // namespace GameEngine
198 
199 #endif /* !RENDERINTERFACES_HPP_ */
Interface for clock.
Definition: RenderInterfaces.hpp:48
~IClock()=default
Destructor.
virtual T & getClock()=0
Get the clock stored.
Interface for event.
Definition: RenderInterfaces.hpp:122
virtual T & getEvent()=0
Get the event stored.
Interfaces for the text font.
Definition: RenderInterfaces.hpp:19
~IFont()=default
Destructor.
virtual void load(const std::string &filename)=0
Load the font.
virtual const T & getFont() const =0
Get the font that will be stored.
interface for music handling
Definition: RenderInterfaces.hpp:79
virtual void play()=0
play the loaded music
virtual void load(const std::string &filename)=0
Load music from a file.
virtual const MusicType & getMusic() const =0
Get the wrapped music instance.
~IMusic()=default
destructor
Interface for rectangle.
Definition: RenderInterfaces.hpp:35
~IRect()=default
Destructor.
virtual const M< T > getBaseRect() const =0
Get the rectangle stored.
Interface for sprite.
Definition: RenderInterfaces.hpp:99
virtual const T & getSprite() const =0
Get the sprite stored.
virtual void setPosition(const Vector2< float > position)=0
set the position of the sprite
virtual void setTextureRect(const IRect< int, rectT > &newRect)=0
set a new rect forof the sprite
~ISprite()=default
Destructor.
virtual void load(const ITexture< TextuT, rectT > &texture, bool resetRect=false)=0
load the sprite
Interface for texture.
Definition: RenderInterfaces.hpp:62
virtual const T & getTexture() const =0
Get the texture stored.
~ITexture()=default
Destructor.
virtual void load(const std::string &filename, const IRect< int, rectT > &area)=0
load the texture
Interface for view.
Definition: RenderInterfaces.hpp:133
virtual const T & getBaseView() const =0
Get the view stored.
virtual void setCenter(const Vector2< float > &center)=0
~IView()=default
Destructor.
virtual Vector2< float > getCenter() const =0
virtual void setViewPort(const Vector2< float > &startingPoint, float width, float height)=0
Interface for the window.
Definition: RenderInterfaces.hpp:152
virtual ~IWindow()=default
Destructor.
virtual void display()=0
display everything that has been drawn
virtual bool isOpen() const =0
check if the window is open
virtual void setFramerateLimit(const float rate)=0
Set the maximum framerate of the window.
virtual const T & getWindow() const =0
Get the window.
virtual void draw(const D &drawable)=0
draw a drawable on the window
virtual void setView(const IView< Vt > &view)=0
set a new view in the window
virtual bool pollEvent(IEvent< Et > &event)=0
pop the event on top of the event queue, if any, and return it.
virtual void create(int width, int height, const std::string &title)=0
create a new window
virtual T & getWindow()=0
Get the window.
virtual void close()=0
close the window
virtual void clear()=0
clear the window
@ D
Definition: Keyboard.hpp:33
@ T
Definition: Keyboard.hpp:49
@ M
Definition: Keyboard.hpp:42
Definition: AssetManager.hpp:15