diff --git a/lib/Ray/CMakeLists.txt b/lib/Ray/CMakeLists.txt index d722f626..eee44ada 100644 --- a/lib/Ray/CMakeLists.txt +++ b/lib/Ray/CMakeLists.txt @@ -22,9 +22,9 @@ set(HEADERS include/Controllers/Keyboard.hpp include/Controllers/Mouse.hpp include/Drawables/ADrawable.hpp - include/Drawables/Basic/Circle.hpp - include/Drawables/Basic/Line.hpp - include/Drawables/Basic/Point.hpp + include/Drawables/2D/Circle.hpp + include/Drawables/2D/Line.hpp + include/Drawables/2D/Point.hpp ) set(SRC diff --git a/lib/Ray/include/Canvas.hpp b/lib/Ray/include/Canvas.hpp index 309d8d90..b432d1bd 100644 --- a/lib/Ray/include/Canvas.hpp +++ b/lib/Ray/include/Canvas.hpp @@ -8,7 +8,7 @@ #ifndef Canvas_HPP_ #define Canvas_HPP_ -#include "Drawables/ADrawable.hpp" +#include "Drawables/ADrawable2D.hpp" namespace Ray { class Canvas { diff --git a/lib/Ray/include/Drawables/Basic/Circle.hpp b/lib/Ray/include/Drawables/2D/Circle.hpp similarity index 93% rename from lib/Ray/include/Drawables/Basic/Circle.hpp rename to lib/Ray/include/Drawables/2D/Circle.hpp index 22a1ebe0..b2655414 100644 --- a/lib/Ray/include/Drawables/Basic/Circle.hpp +++ b/lib/Ray/include/Drawables/2D/Circle.hpp @@ -9,10 +9,10 @@ #define CIRCLE_HPP_ #include -#include "Drawables/ADrawable.hpp" +#include "Drawables/ADrawable2D.hpp" -namespace Ray { - class Circle: public ADrawable +namespace Ray::Drawable3D { + class Circle: public ADrawable2D { public: //! @brief Circle constructor diff --git a/lib/Ray/include/Drawables/Basic/Line.hpp b/lib/Ray/include/Drawables/2D/Line.hpp similarity index 94% rename from lib/Ray/include/Drawables/Basic/Line.hpp rename to lib/Ray/include/Drawables/2D/Line.hpp index 2e177799..aa781a35 100644 --- a/lib/Ray/include/Drawables/Basic/Line.hpp +++ b/lib/Ray/include/Drawables/2D/Line.hpp @@ -9,10 +9,10 @@ #define LINE_HPP_ #include -#include "Drawables/ADrawable.hpp" +#include "Drawables/ADrawable2D.hpp" -namespace Ray { - class Line: public ADrawable +namespace Ray::Drawable3D { + class Line: public ADrawable2D { public: diff --git a/lib/Ray/include/Drawables/Basic/Point.hpp b/lib/Ray/include/Drawables/2D/Point.hpp similarity index 90% rename from lib/Ray/include/Drawables/Basic/Point.hpp rename to lib/Ray/include/Drawables/2D/Point.hpp index 934210ca..61f87741 100644 --- a/lib/Ray/include/Drawables/Basic/Point.hpp +++ b/lib/Ray/include/Drawables/2D/Point.hpp @@ -9,10 +9,10 @@ #define PIXEL_HPP_ #include -#include "Drawables/ADrawable.hpp" +#include "Drawables/ADrawable2D.hpp" -namespace Ray { - class Point: public ADrawable +namespace Ray::Drawable3D { + class Point: public ADrawable2D { public: //! @brief Point constructor diff --git a/lib/Ray/include/Drawables/Basic/Rectangle.hpp b/lib/Ray/include/Drawables/2D/Rectangle.hpp similarity index 94% rename from lib/Ray/include/Drawables/Basic/Rectangle.hpp rename to lib/Ray/include/Drawables/2D/Rectangle.hpp index 9aeaed70..a3eb6f2f 100644 --- a/lib/Ray/include/Drawables/Basic/Rectangle.hpp +++ b/lib/Ray/include/Drawables/2D/Rectangle.hpp @@ -9,10 +9,10 @@ #define RECTANGLE_HPP_ #include -#include "Drawables/ADrawable.hpp" +#include "Drawables/ADrawable2D.hpp" -namespace Ray { - class Rectangle: public ADrawable +namespace Ray::Drawable3D { + class Rectangle: public ADrawable2D { public: //! @brief Rectangle constructor diff --git a/lib/Ray/include/Drawables/Basic/Text.hpp b/lib/Ray/include/Drawables/2D/Text.hpp similarity index 88% rename from lib/Ray/include/Drawables/Basic/Text.hpp rename to lib/Ray/include/Drawables/2D/Text.hpp index 78005c40..8cf9e3ec 100644 --- a/lib/Ray/include/Drawables/Basic/Text.hpp +++ b/lib/Ray/include/Drawables/2D/Text.hpp @@ -8,11 +8,11 @@ #ifndef TEXT_HPP_ #define TEXT_HPP_ -#include "Drawables/ADrawable.hpp" +#include "Drawables/ADrawable2D.hpp" #include -namespace Ray { - class Text: public ADrawable +namespace Ray::Drawable3D { + class Text: public ADrawable2D { public: //! @brief Text constructor @@ -45,6 +45,9 @@ namespace Ray { //! @return the font size int getFontSize(void); + //! @return set font + Text &setFont(const Font &font); + //! @brief set text content Text &setText(const std::string &text); @@ -55,6 +58,9 @@ namespace Ray { //! @brief Text, just text std::string _text; + //! @brief Font + Font _font; + //! @brief font size of the text int _size; }; diff --git a/lib/Ray/include/Drawables/3D/Circle.hpp b/lib/Ray/include/Drawables/3D/Circle.hpp new file mode 100644 index 00000000..f10384c0 --- /dev/null +++ b/lib/Ray/include/Drawables/3D/Circle.hpp @@ -0,0 +1,55 @@ +/* +** EPITECH PROJECT, 2021 +** Bomberman +** File description: +** Pixel +*/ + +#ifndef CIRCLE_HPP_ +#define CIRCLE_HPP_ + +#include +#include "Drawables/ADrawable3D.hpp" + +namespace Ray::Drawable3D { + class Circle: public ADrawable3D + { + public: + //! @brief Circle constructor + //! @param centerPosition position of the center + //! @param radius radius of the circle(in percentage) + //! @param Color Color of the circle + Circle(Vector3 centerPosition, int radius, Color color); + + + //! @brief A default copy constructor + Circle(const Circle &) = default; + + //! @brief A circle is assignable + Circle &operator=(const Circle &) = default; + + //! @brief A default destructor + ~Circle() = default; + + //! @return the radius of the circle + int getRadius(void) const; + + //! @brief set radius + Circle &setRadius(int radius) const; + + //! @return the position of the center + const Vector3 &getCenterPos(void) const; + + //! @brief set pos of center + Circle &setRadius(Vector3 pos) const; + + private: + //! @brief Radius of the circle (in percentage) + int _radius; + + //! @brief position of the center + Vector3 _centerPos; + }; +}; + +#endif /* !PIXEL_HPP_ */ diff --git a/lib/Ray/include/Drawables/3D/Line.hpp b/lib/Ray/include/Drawables/3D/Line.hpp new file mode 100644 index 00000000..f5c52d87 --- /dev/null +++ b/lib/Ray/include/Drawables/3D/Line.hpp @@ -0,0 +1,57 @@ +/* +** EPITECH PROJECT, 2021 +** Bomberman +** File description: +** Pixel +*/ + +#ifndef LINE_HPP_ +#define LINE_HPP_ + +#include +#include "Drawables/ADrawable3D.hpp" + +namespace Ray::Drawable3D { + class Line: public ADrawable3D + { + public: + //! @brief Line constructor + //! @param startPosition position of top-left point (in percentage) + //! @param startPosition position of bottom-rigth point (in percentage) + //! @param Color Color of the line + Line(Vector3 startPosition, Vector3 endPosition, Color color); + + //! @brief A default copy constructor + Line(const Line &) = default; + + //! @brief A line is assignable + Line &operator=(const Line &) = default; + + //! @brief A default destructor + ~Line() = default; + + //! @return the length of the line + int getLength(void) const; + + //! @return the start position of the line + const Vector3 &getStartPosition(void) const; + + //! @return the end position of the line + const Vector3 &getEndPosition(void) const; + + //! @brief Set start position + Line &setStartPosition(Vector3 startPosition); + + //! @brief Set end position + Line &setEndPosition(Vector3 endPosition); + + + private: + //! @brief start position + Vector3 _startPosition; + //! @brief end position + Vector3 _endPosition; + }; +}; + +#endif /* !PIXEL_HPP_ */ diff --git a/lib/Ray/include/Drawables/3D/Point.hpp b/lib/Ray/include/Drawables/3D/Point.hpp new file mode 100644 index 00000000..572633a2 --- /dev/null +++ b/lib/Ray/include/Drawables/3D/Point.hpp @@ -0,0 +1,43 @@ +/* +** EPITECH PROJECT, 2021 +** Bomberman +** File description: +** Pixel +*/ + +#ifndef PIXEL_HPP_ +#define PIXEL_HPP_ + +#include +#include "Drawables/ADrawable3D.hpp" + +namespace Ray::Drawable3D { + class Point: public ADrawable3D + { + public: + //! @brief Point constructor + //! @param position position of point + //! @param Color Color of the circle + Point(Vector3 position, Color); + + //! @brief A default copy constructor + Point(const Point &) = default; + + //! @brief A point is assignable + Point &operator=(const Point &) = default; + + //! @brief A default destructor + ~Point() = default; + + //! @return the position of the point + const Vector3 &getPosition(void) const; + + //! @brief Set position + Point &setPosition(Vector3 Position); + private: + //! @brief point position + Vector3 _position; + }; +}; + +#endif /* !PIXEL_HPP_ */ diff --git a/lib/Ray/include/Drawables/ADrawable.hpp b/lib/Ray/include/Drawables/ADrawable2D.hpp similarity index 69% rename from lib/Ray/include/Drawables/ADrawable.hpp rename to lib/Ray/include/Drawables/ADrawable2D.hpp index 7e46b134..c0270ccd 100644 --- a/lib/Ray/include/Drawables/ADrawable.hpp +++ b/lib/Ray/include/Drawables/ADrawable2D.hpp @@ -10,30 +10,26 @@ #include #include -#include "Drawables/Basic/Circle.hpp" -#include "Drawables/Basic/Line.hpp" -#include "Drawables/Basic/Rectangle.hpp" -#include "Drawables/Basic/Point.hpp" -namespace Ray { - class ADrawable +namespace Ray::Drawable3D { + class ADrawable2D { public: //! @brief ADrawable constructor //! @param poition position of top-left point (in percentage) //! @param Color Color of the color - ADrawable(Vector2 position, Color color); + ADrawable2D(Vector2 position, Color color); //! @brief ADrawable constructor //! @param x x-position of top-left point (in percentage) //! @param y y-position of top-left point (in percentage) //! @param Color Color of the color - ADrawable(int x, int y, Color color); + ADrawable2D(int x, int y, Color color); //! @brief A default copy constructor - ADrawable(const ADrawable &) = default; + ADrawable2D(const ADrawable2D &) = default; //! @brief A default destructor - virtual ~ADrawable() = 0; + virtual ~ADrawable2D() = 0; //! @return the top-left position of the ADrawable const Vector2 &getPosition(void) const; @@ -42,13 +38,13 @@ namespace Ray { const Color &getColor(void) const; //! @brief set Top-left position - ADrawable &setPosition(const Vector2 &position); + ADrawable2D &setPosition(const Vector2 &position); //! @brief set Top-left position - ADrawable &setPosition(int x, int y); + ADrawable2D &setPosition(int x, int y); //! @brief set color - ADrawable &setColor(const Color &color) const; + ADrawable2D &setColor(const Color &color) const; private: //! @brief Top-left position (in percentage) diff --git a/lib/Ray/include/Drawables/ADrawable3D.hpp b/lib/Ray/include/Drawables/ADrawable3D.hpp new file mode 100644 index 00000000..ae271d21 --- /dev/null +++ b/lib/Ray/include/Drawables/ADrawable3D.hpp @@ -0,0 +1,41 @@ +/* +** EPITECH PROJECT, 2021 +** Bomberman +** File description: +** ADrawable +*/ + +#ifndef ADrawable_HPP_ +#define ADrawable_HPP_ + +#include +#include + +namespace Ray::Drawable3D { + class ADrawable3D + { + public: + //! @param Color Color of the drawable + ADrawable3D(Color color); + + //! @brief A default copy constructor + ADrawable3D(const ADrawable3D &) = default; + + //! @brief A default destructor + virtual ~ADrawable3D() = 0; + + + //! @return the color of the ADrawable + const Color &getColor(void) const; + + //! @brief set color + ADrawable3D &setColor(const Color &color) const; + + private: + //! @brief Color of the ADrawable + Color _color; + + }; +}; + +#endif /* !ADrawable_HPP_ */ diff --git a/lib/Ray/include/Drawables/Texture.hpp b/lib/Ray/include/Drawables/Texture.hpp new file mode 100644 index 00000000..e3235233 --- /dev/null +++ b/lib/Ray/include/Drawables/Texture.hpp @@ -0,0 +1,56 @@ +/* +** EPITECH PROJECT, 2021 +** Bomberman +** File description: +** Texture +*/ + +#ifndef TEXTURE_HPP_ +#define TEXTURE_HPP_ + +#include +#include +#include "Canvas.hpp" + +namespace Ray +{ + class Texture: public Canvas { + public: + //! @brief Create an texture, loading a file + //! @param filename: path to file to load + Texture(const std::string &filename); + + //! @brief Create an texture, from an image + //! @param image: reference to image to create texture from + Texture(const Image &image); + + //! @brief A default copy constructor + Texture(const Texture &); + + //! @brief A default constructor, no ressources loaded + Texture(); + + //! @brief An image is assignable + Texture &operator=(const Texture &) = default; + + //! @brief Texture destructor, will unload ressources + ~Texture(); + + //! @brief load ressources from file + //! @param filename: path of input + bool load(const std::string &filename); + + //! @brief unload ressources + bool unload(); + + //! @brief get image + Image toImage(void) const; + + protected: + private: + //! @brief Texture, really, that's just it... + ::Texture _image; + }; +} + +#endif /* !IMAGE_HPP_ */ diff --git a/lib/Ray/include/Font.hpp b/lib/Ray/include/Font.hpp new file mode 100644 index 00000000..ef09cbca --- /dev/null +++ b/lib/Ray/include/Font.hpp @@ -0,0 +1,49 @@ +/* +** EPITECH PROJECT, 2021 +** Bomberman +** File description: +** Font +*/ + +#ifndef FONT_HPP_ +#define FONT_HPP_ + +#include +#include + +namespace Ray +{ + class Font { + public: + //! @brief Create an font, loading a file + //! @param filename: path to file to load + Font(const std::string &filename); + + //! @brief A default copy constructor + Font(const Font &); + + //! @brief A default constructor, no ressources loaded + Font(); + + //! @brief An image is assignable + Font &operator=(const Font &) = default; + + //! @brief Unload font at destruction + ~Font(); + + //! @brief load font from file + //! @param filename: path of input + bool load(const std::string &filename); + + //! @brief unload ressources + bool unload(); + + + protected: + private: + //! @brief Font, really, that's just it... + ::Font _font; + }; +} + +#endif \ No newline at end of file diff --git a/lib/Ray/include/Window.hpp b/lib/Ray/include/Window.hpp index b72defa5..1cbe4715 100644 --- a/lib/Ray/include/Window.hpp +++ b/lib/Ray/include/Window.hpp @@ -85,6 +85,9 @@ namespace Ray { //! @brief draw circle void draw(const Circle &); + //! @brief draw texture at position + void draw(const Texture &, Vector2 position, Color tint); + private: //! @brief Dimension of window Ray::Vector2 _dimensions;