mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-05 10:59:48 +00:00
drawables abstract
This commit is contained in:
+53
-51
@@ -12,60 +12,62 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
|
||||
endif ()
|
||||
|
||||
set(HEADERS
|
||||
include/Canvas.hpp
|
||||
include/Color.hpp
|
||||
include/Font.hpp
|
||||
include/IRessource.hpp
|
||||
include/Matrix.hpp
|
||||
include/Mesh.hpp
|
||||
include/Model.hpp
|
||||
include/Vector.hpp
|
||||
include/Window.hpp
|
||||
include/Audio/IAudio.hpp
|
||||
include/Audio/Music.hpp
|
||||
include/Audio/Sound.hpp
|
||||
include/Camera/Camera2D.hpp
|
||||
include/Camera/Camera3D.hpp
|
||||
include/Camera/CameraMode.hpp
|
||||
include/Camera/CameraProjection.hpp
|
||||
include/Camera/ICamera.hpp
|
||||
include/Controllers/Gamepad.hpp
|
||||
include/Controllers/Keyboard.hpp
|
||||
include/Controllers/Mouse.hpp
|
||||
include/Drawables/ADrawable2D.hpp
|
||||
include/Drawables/ADrawable3D.hpp
|
||||
include/Drawables/IDrawable.hpp
|
||||
include/Drawables/Image.hpp
|
||||
include/Drawables/Texture.hpp
|
||||
include/Drawables/2D/Circle.hpp
|
||||
include/Drawables/2D/Line.hpp
|
||||
include/Drawables/2D/Point.hpp
|
||||
include/Drawables/2D/Rectangle.hpp
|
||||
include/Drawables/2D/Text.hpp
|
||||
include/Drawables/2D/Triangle.hpp
|
||||
include/Drawables/3D/Circle.hpp
|
||||
include/Drawables/3D/Cylinder.hpp
|
||||
include/Drawables/3D/Grid.hpp
|
||||
include/Drawables/3D/Line.hpp
|
||||
include/Drawables/3D/Plane.hpp
|
||||
include/Drawables/3D/Point.hpp
|
||||
include/Drawables/3D/Ray.hpp
|
||||
include/Drawables/3D/Sphere.hpp
|
||||
include/Drawables/3D/Triangle.hpp
|
||||
include/Canvas.hpp
|
||||
include/Color.hpp
|
||||
include/Font.hpp
|
||||
include/IRessource.hpp
|
||||
include/Matrix.hpp
|
||||
include/Mesh.hpp
|
||||
include/Model.hpp
|
||||
include/Vector.hpp
|
||||
include/Window.hpp
|
||||
include/Audio/IAudio.hpp
|
||||
include/Audio/Music.hpp
|
||||
include/Audio/Sound.hpp
|
||||
include/Camera/Camera2D.hpp
|
||||
include/Camera/Camera3D.hpp
|
||||
include/Camera/CameraMode.hpp
|
||||
include/Camera/CameraProjection.hpp
|
||||
include/Camera/ICamera.hpp
|
||||
include/Controllers/Gamepad.hpp
|
||||
include/Controllers/Keyboard.hpp
|
||||
include/Controllers/Mouse.hpp
|
||||
include/Drawables/ADrawable2D.hpp
|
||||
include/Drawables/ADrawable3D.hpp
|
||||
include/Drawables/IDrawable.hpp
|
||||
include/Drawables/Image.hpp
|
||||
include/Drawables/Texture.hpp
|
||||
include/Drawables/2D/Circle.hpp
|
||||
include/Drawables/2D/Line.hpp
|
||||
include/Drawables/2D/Point.hpp
|
||||
include/Drawables/2D/Rectangle.hpp
|
||||
include/Drawables/2D/Text.hpp
|
||||
include/Drawables/2D/Triangle.hpp
|
||||
include/Drawables/3D/Circle.hpp
|
||||
include/Drawables/3D/Cylinder.hpp
|
||||
include/Drawables/3D/Grid.hpp
|
||||
include/Drawables/3D/Line.hpp
|
||||
include/Drawables/3D/Plane.hpp
|
||||
include/Drawables/3D/Point.hpp
|
||||
include/Drawables/3D/Ray.hpp
|
||||
include/Drawables/3D/Sphere.hpp
|
||||
include/Drawables/3D/Triangle.hpp
|
||||
)
|
||||
|
||||
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
|
||||
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
|
||||
src/Drawables/ADrawable2D.cpp
|
||||
src/Drawables/ADrawable3D.cpp
|
||||
)
|
||||
|
||||
add_library(${LIB_NAME} STATIC ${SRC} ${HEADERS})
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <raylib.h>
|
||||
#include <Vector.hpp>
|
||||
#include "Drawables/IDrawable.hpp"
|
||||
#include "Color.hpp"
|
||||
|
||||
namespace RAY::Drawables::Drawables2D {
|
||||
class ADrawable2D: public IDrawable
|
||||
@@ -19,12 +20,12 @@ namespace RAY::Drawables::Drawables2D {
|
||||
//! @brief ADrawable constructor
|
||||
//! @param poition position of top-left point
|
||||
//! @param Color Color of the color
|
||||
ADrawable2D(const Vector2 &position, RAY::Color color);
|
||||
ADrawable2D(const Vector2 &position, const RAY::Color &color);
|
||||
//! @brief ADrawable constructor
|
||||
//! @param x x-position of top-left point
|
||||
//! @param y y-position of top-left point
|
||||
//! @param Color Color of the color
|
||||
ADrawable2D(int x, int y, Color color);
|
||||
ADrawable2D(int x, int y, const RAY::Color &color);
|
||||
|
||||
//! @brief A default copy constructor
|
||||
ADrawable2D(const ADrawable2D &) = default;
|
||||
@@ -36,7 +37,7 @@ namespace RAY::Drawables::Drawables2D {
|
||||
const Vector2 &getPosition(void) const;
|
||||
|
||||
//! @return the color of the ADrawable
|
||||
const Color &getColor(void) const;
|
||||
const RAY::Color &getColor(void) const;
|
||||
|
||||
//! @brief set Top-left position
|
||||
ADrawable2D &setPosition(const Vector2 &position);
|
||||
@@ -45,7 +46,7 @@ namespace RAY::Drawables::Drawables2D {
|
||||
ADrawable2D &setPosition(int x, int y);
|
||||
|
||||
//! @brief set color
|
||||
ADrawable2D &setColor(const Color &color) const;
|
||||
ADrawable2D &setColor(const Color &color);
|
||||
|
||||
//! @brief Draw drawble on window
|
||||
virtual void drawOn(Window &) = 0;
|
||||
|
||||
@@ -10,14 +10,15 @@
|
||||
|
||||
#include <raylib.h>
|
||||
#include <Vector.hpp>
|
||||
#include "Drawbles/IDrawable.hpp"
|
||||
#include "Drawables/IDrawable.hpp"
|
||||
#include "Color.hpp"
|
||||
|
||||
namespace RAY::Drawables::Drawables3D {
|
||||
class ADrawable3D: public IDrawable
|
||||
{
|
||||
public:
|
||||
//! @param Color Color of the drawable
|
||||
ADrawable3D(Color color);
|
||||
ADrawable3D(const RAY::Color &color);
|
||||
|
||||
//! @brief A default copy constructor
|
||||
ADrawable3D(const ADrawable3D &) = default;
|
||||
@@ -26,14 +27,14 @@ namespace RAY::Drawables::Drawables3D {
|
||||
virtual ~ADrawable3D() = default;
|
||||
|
||||
//! @brief Draw drawble on window
|
||||
void drawOn(Window &);
|
||||
virtual void drawOn(Window &) = 0;
|
||||
|
||||
|
||||
//! @return the color of the ADrawable
|
||||
const Color &getColor(void) const;
|
||||
|
||||
//! @brief set color
|
||||
ADrawable3D &setColor(const Color &color) const;
|
||||
ADrawable3D &setColor(const RAY::Color &color);
|
||||
|
||||
private:
|
||||
//! @brief Color of the ADrawable
|
||||
|
||||
@@ -7,39 +7,44 @@
|
||||
|
||||
#include "Drawables/ADrawable2D.hpp"
|
||||
|
||||
RAY::Drawables::Drawables2D::ADrawable2D::ADrawable2D(const Vector2 &position, RAY::Color color):
|
||||
RAY::Drawables::Drawables2D::ADrawable2D::ADrawable2D(const Vector2 &position, const RAY::Color &color):
|
||||
_color(color), _position(position)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
RAY::Drawables::Drawables2D::ADrawable2D(int x, int y, RAY::Color color)
|
||||
RAY::Drawables::Drawables2D::ADrawable2D::ADrawable2D(int x, int y, const RAY::Color &color):
|
||||
_color(color), _position({(float)x, (float)y})
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const Vector2 &RAY::Drawables::Drawables2D::getPosition(void) const
|
||||
const Vector2 &RAY::Drawables::Drawables2D::ADrawable2D::getPosition(void) const
|
||||
{
|
||||
|
||||
return this->_position;
|
||||
}
|
||||
|
||||
const Color &RAY::Drawables::Drawables2D::getColor(void) const
|
||||
const RAY::Color &RAY::Drawables::Drawables2D::ADrawable2D::getColor(void) const
|
||||
{
|
||||
|
||||
return this->_color;
|
||||
}
|
||||
|
||||
ADrawable2D &RAY::Drawables::Drawables2D::setPosition(const Vector2 &position)
|
||||
RAY::Drawables::Drawables2D::ADrawable2D &RAY::Drawables::Drawables2D::ADrawable2D::setPosition(const Vector2 &position)
|
||||
{
|
||||
|
||||
this->_position = position;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ADrawable2D &RAY::Drawables::Drawables2D::setPosition(int x, int y)
|
||||
RAY::Drawables::Drawables2D::ADrawable2D &RAY::Drawables::Drawables2D::ADrawable2D::setPosition(int x, int y)
|
||||
{
|
||||
|
||||
this->_position.x = x;
|
||||
this->_position.y = y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ADrawable2D &RAY::Drawables::Drawables2D::setColor(const Color &color) const
|
||||
RAY::Drawables::Drawables2D::ADrawable2D &RAY::Drawables::Drawables2D::ADrawable2D::setColor(const Color &color)
|
||||
{
|
||||
|
||||
this->_color = color;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2021
|
||||
** Bomberman
|
||||
** File description:
|
||||
** ADrawable3D
|
||||
*/
|
||||
|
||||
#include "Drawables/ADrawable3D.hpp"
|
||||
|
||||
RAY::Drawables::Drawables3D::ADrawable3D::ADrawable3D(const RAY::Color &color):
|
||||
_color(color)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const RAY::Color &RAY::Drawables::Drawables3D::ADrawable3D::getColor(void) const
|
||||
{
|
||||
return this->_color;
|
||||
}
|
||||
|
||||
RAY::Drawables::Drawables3D::ADrawable3D &RAY::Drawables::Drawables3D::ADrawable3D::setColor(const RAY::Color &color)
|
||||
{
|
||||
this->_color = color;
|
||||
return *this;
|
||||
}
|
||||
Reference in New Issue
Block a user