mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-05 02:49:57 +00:00
image + texture
This commit is contained in:
@@ -0,0 +1 @@
|
||||
build/
|
||||
@@ -68,6 +68,8 @@ set(SRC
|
||||
src/Controllers/Mouse.cpp
|
||||
src/Drawables/ADrawable2D.cpp
|
||||
src/Drawables/ADrawable3D.cpp
|
||||
src/Drawables/Image.cpp
|
||||
src/Drawables/Texture.cpp
|
||||
)
|
||||
|
||||
add_library(${LIB_NAME} STATIC ${SRC} ${HEADERS})
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace RAY::Drawables::Drawables2D {
|
||||
Circle &setRadius(int radius) const;
|
||||
|
||||
//! @brief Draw Circle on window
|
||||
void drawOn(Window &);
|
||||
void drawOn(Canvas &);
|
||||
|
||||
private:
|
||||
//! @brief Radius of the circle
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace RAY::Drawables::Drawables2D {
|
||||
Line &setRotation(int);
|
||||
|
||||
//! @brief Draw line on window
|
||||
void drawOn(Window &);
|
||||
void drawOn(Canvas &);
|
||||
private:
|
||||
//! @brief Length of the line
|
||||
int _length;
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace RAY::Drawables::Drawables2D {
|
||||
~Point() = default;
|
||||
|
||||
//! @brief Draw point on window
|
||||
void drawOn(Window &);
|
||||
void drawOn(Canvas &);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace RAY::Drawables::Drawables2D {
|
||||
Rectangle &setDimensions(int x, int y);
|
||||
|
||||
//! @brief Draw rectangle on window
|
||||
void drawOn(Window &);
|
||||
void drawOn(Canvas &);
|
||||
|
||||
private:
|
||||
//! @brief Diemnsions of the rectangle
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace RAY::Drawables::Drawables2D {
|
||||
Text &setFontSize(int size);
|
||||
|
||||
//! @brief Draw text on window
|
||||
void drawOn(Window &);
|
||||
void drawOn(Canvas &);
|
||||
|
||||
private:
|
||||
//! @brief Text, just text
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace RAY::Drawables::Drawables2D {
|
||||
Triangle &setPositionC(Vector2);
|
||||
|
||||
//! @brief Draw triangle on window
|
||||
void drawOn(Window &);
|
||||
void drawOn(Canvas &);
|
||||
|
||||
private:
|
||||
//! @brief Position of A
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace RAY::Drawables::Drawables3D {
|
||||
Circle &setRadius(const Vector3 &pos) const;
|
||||
|
||||
//! @brief Draw circle on window
|
||||
void drawOn(Window &);
|
||||
void drawOn(Canvas &);
|
||||
|
||||
private:
|
||||
//! @brief Radius of the circle
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace RAY::Drawables::Drawables3D {
|
||||
Cylinder &setHeigth(float heigth) const;
|
||||
|
||||
//! @brief Draw cylinder on window
|
||||
void drawOn(Window &);
|
||||
void drawOn(Canvas &);
|
||||
|
||||
private:
|
||||
//! @brief Radius of the cylinder
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace RAY::Drawables::Drawables3D {
|
||||
Grid &setSpacing(float spacing);
|
||||
|
||||
//! @brief Draw grid on window
|
||||
void drawOn(Window &);
|
||||
void drawOn(Canvas &);
|
||||
|
||||
private:
|
||||
//! @brief Grid slices
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace RAY::Drawables::Drawables3D {
|
||||
Line &setEndPosition(const Vector3 &endPosition);
|
||||
|
||||
//! @brief Draw line on window
|
||||
void drawOn(Window &);
|
||||
void drawOn(Canvas &);
|
||||
|
||||
private:
|
||||
//! @brief start position
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace RAY::Drawables::Drawables3D {
|
||||
Plane &setDimensions(const Vector3 &dimensions);
|
||||
|
||||
//! @brief Draw plane on window
|
||||
void drawOn(Window &);
|
||||
void drawOn(Canvas &);
|
||||
private:
|
||||
//! @brief plane position
|
||||
Vector3 _position;
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace RAY::Drawables::Drawables3D {
|
||||
Point &setPosition(const Vector3 &Position);
|
||||
|
||||
//! @brief Draw point on window
|
||||
void drawOn(Window &);
|
||||
void drawOn(Canvas &);
|
||||
|
||||
private:
|
||||
//! @brief point position
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace RAY::Drawables::Drawables3D {
|
||||
Ray &setDirection(const Vector3 &dimensions);
|
||||
|
||||
//! @brief Draw ray on window
|
||||
void drawOn(Window &);
|
||||
void drawOn(Canvas &);
|
||||
|
||||
private:
|
||||
//! @brief start position
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace RAY::Drawables::Drawables3D {
|
||||
Sphere &setRadius(const Vector3 &pos) const;
|
||||
|
||||
//! @brief Draw sphere on window
|
||||
void drawOn(Window &);
|
||||
void drawOn(Canvas &);
|
||||
|
||||
private:
|
||||
//! @brief Radius of the sphere
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace RAY::Drawables::Drawables3D {
|
||||
Triangle &setPositionC(Vector3);
|
||||
|
||||
//! @brief Draw triangle on window
|
||||
void drawOn(Window &);
|
||||
void drawOn(Canvas &);
|
||||
|
||||
private:
|
||||
//! @brief Position of A
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <Vector.hpp>
|
||||
#include "Drawables/IDrawable.hpp"
|
||||
#include "Color.hpp"
|
||||
#include "Canvas.hpp"
|
||||
|
||||
namespace RAY::Drawables::Drawables2D {
|
||||
class ADrawable2D: public IDrawable
|
||||
@@ -49,7 +50,7 @@ namespace RAY::Drawables::Drawables2D {
|
||||
ADrawable2D &setColor(const Color &color);
|
||||
|
||||
//! @brief Draw drawble on window
|
||||
virtual void drawOn(Window &) = 0;
|
||||
virtual void drawOn(RAY::Canvas &) = 0;
|
||||
|
||||
private:
|
||||
//! @brief Top-left position
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace RAY::Drawables::Drawables3D {
|
||||
virtual ~ADrawable3D() = default;
|
||||
|
||||
//! @brief Draw drawble on window
|
||||
virtual void drawOn(Window &) = 0;
|
||||
virtual void drawOn(Canvas &) = 0;
|
||||
|
||||
|
||||
//! @return the color of the ADrawable
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
|
||||
namespace RAY
|
||||
{
|
||||
class Window;
|
||||
class Canvas;
|
||||
namespace Drawables {
|
||||
class IDrawable {
|
||||
public:
|
||||
virtual ~IDrawable() = 0;
|
||||
|
||||
virtual void drawOn(RAY::Window &) = 0;
|
||||
virtual void drawOn(RAY::Canvas &) = 0;
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <string>
|
||||
#include "Canvas.hpp"
|
||||
#include "IRessource.hpp"
|
||||
#include "Drawables/IDrawable.hpp"
|
||||
|
||||
namespace RAY
|
||||
{
|
||||
@@ -22,7 +23,7 @@ namespace RAY
|
||||
Image(const std::string &filename);
|
||||
|
||||
//! @brief A default copy constructor
|
||||
Image(const Image &);
|
||||
Image(const Image &) = default;
|
||||
|
||||
//! @brief A default constructor, no ressources loaded
|
||||
Image();
|
||||
@@ -48,7 +49,7 @@ namespace RAY
|
||||
const ::Image &getImage(void) const;
|
||||
|
||||
//! @brief draw drawable
|
||||
void draw(const Drawables::IDrawable &);
|
||||
void draw(Drawables::IDrawable &);
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace RAY
|
||||
Texture(const Image &image);
|
||||
|
||||
//! @brief A default copy constructor
|
||||
Texture(const Texture &);
|
||||
Texture(const Texture &) = default;
|
||||
|
||||
//! @brief A default constructor, no ressources loaded
|
||||
Texture();
|
||||
@@ -53,7 +53,7 @@ namespace RAY
|
||||
protected:
|
||||
private:
|
||||
//! @brief Texture, really, that's just it...
|
||||
::Texture _image;
|
||||
::Texture _texture;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
#include "Drawables/ADrawable2D.hpp"
|
||||
|
||||
RAY::Drawables::Drawables2D::ADrawable2D::ADrawable2D(const Vector2 &position, const RAY::Color &color):
|
||||
_color(color), _position(position)
|
||||
_position(position), _color(color)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
RAY::Drawables::Drawables2D::ADrawable2D::ADrawable2D(int x, int y, const RAY::Color &color):
|
||||
_color(color), _position({(float)x, (float)y})
|
||||
_position({(float)x, (float)y}), _color(color)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2021
|
||||
** Bomberman
|
||||
** File description:
|
||||
** Image
|
||||
*/
|
||||
|
||||
#include "Drawables/Image.hpp"
|
||||
|
||||
RAY::Image::Image(const std::string &filename):
|
||||
_image(LoadImage(filename.c_str()))
|
||||
{
|
||||
}
|
||||
|
||||
RAY::Image::Image()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RAY::Image::~Image()
|
||||
{
|
||||
UnloadImage(_image);
|
||||
}
|
||||
|
||||
bool RAY::Image::load(const std::string &filename)
|
||||
{
|
||||
this->_image = LoadImage(filename.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RAY::Image::exportTo(const std::string &outputPath)
|
||||
{
|
||||
ExportImage(_image, outputPath.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RAY::Image::unload()
|
||||
{
|
||||
UnloadImage(_image);
|
||||
return true;
|
||||
}
|
||||
|
||||
const ::Image &RAY::Image::getImage(void) const
|
||||
{
|
||||
return _image;
|
||||
}
|
||||
|
||||
void RAY::Image::draw(Drawables::IDrawable & drawable)
|
||||
{
|
||||
drawable.drawOn(*this);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2021
|
||||
** Bomberman
|
||||
** File description:
|
||||
** Texture
|
||||
*/
|
||||
|
||||
#include "Drawables/Texture.hpp"
|
||||
|
||||
RAY::Texture::Texture(const std::string &filename):
|
||||
_texture(LoadTexture(filename.c_str()))
|
||||
{
|
||||
}
|
||||
|
||||
RAY::Texture::Texture(const Image &image):
|
||||
_texture(LoadTextureFromImage(image))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RAY::Texture::Texture()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RAY::Texture::~Texture()
|
||||
{
|
||||
UnloadTexture(this->_texture);
|
||||
}
|
||||
|
||||
bool RAY::Texture::load(const std::string &filename)
|
||||
{
|
||||
this->_texture = LoadTexture(filename.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
Image RAY::Texture::toImage(void) const
|
||||
{
|
||||
return GetTextureData(_texture);
|
||||
}
|
||||
|
||||
const ::Texture &RAY::Texture::getTexture(void) const
|
||||
{
|
||||
return this->_texture;
|
||||
}
|
||||
Reference in New Issue
Block a user