mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-04 10:44:42 +00:00
some 3D shapes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#ifndef Canvas_HPP_
|
||||
#define Canvas_HPP_
|
||||
|
||||
#include "Drawables/ADrawable.hpp"
|
||||
#include "Drawables/ADrawable2D.hpp"
|
||||
|
||||
namespace Ray {
|
||||
class Canvas {
|
||||
|
||||
+3
-3
@@ -9,10 +9,10 @@
|
||||
#define CIRCLE_HPP_
|
||||
|
||||
#include <raylib.h>
|
||||
#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
|
||||
@@ -9,10 +9,10 @@
|
||||
#define LINE_HPP_
|
||||
|
||||
#include <raylib.h>
|
||||
#include "Drawables/ADrawable.hpp"
|
||||
#include "Drawables/ADrawable2D.hpp"
|
||||
|
||||
namespace Ray {
|
||||
class Line: public ADrawable
|
||||
namespace Ray::Drawable3D {
|
||||
class Line: public ADrawable2D
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
#define PIXEL_HPP_
|
||||
|
||||
#include <raylib.h>
|
||||
#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
|
||||
+3
-3
@@ -9,10 +9,10 @@
|
||||
#define RECTANGLE_HPP_
|
||||
|
||||
#include <raylib.h>
|
||||
#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
|
||||
@@ -8,11 +8,11 @@
|
||||
#ifndef TEXT_HPP_
|
||||
#define TEXT_HPP_
|
||||
|
||||
#include "Drawables/ADrawable.hpp"
|
||||
#include "Drawables/ADrawable2D.hpp"
|
||||
#include <string>
|
||||
|
||||
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;
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2021
|
||||
** Bomberman
|
||||
** File description:
|
||||
** Pixel
|
||||
*/
|
||||
|
||||
#ifndef CIRCLE_HPP_
|
||||
#define CIRCLE_HPP_
|
||||
|
||||
#include <raylib.h>
|
||||
#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_ */
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2021
|
||||
** Bomberman
|
||||
** File description:
|
||||
** Pixel
|
||||
*/
|
||||
|
||||
#ifndef LINE_HPP_
|
||||
#define LINE_HPP_
|
||||
|
||||
#include <raylib.h>
|
||||
#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_ */
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2021
|
||||
** Bomberman
|
||||
** File description:
|
||||
** Pixel
|
||||
*/
|
||||
|
||||
#ifndef PIXEL_HPP_
|
||||
#define PIXEL_HPP_
|
||||
|
||||
#include <raylib.h>
|
||||
#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_ */
|
||||
+9
-13
@@ -10,30 +10,26 @@
|
||||
|
||||
#include <raylib.h>
|
||||
#include <Vector.hpp>
|
||||
#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)
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2021
|
||||
** Bomberman
|
||||
** File description:
|
||||
** ADrawable
|
||||
*/
|
||||
|
||||
#ifndef ADrawable_HPP_
|
||||
#define ADrawable_HPP_
|
||||
|
||||
#include <raylib.h>
|
||||
#include <Vector.hpp>
|
||||
|
||||
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_ */
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2021
|
||||
** Bomberman
|
||||
** File description:
|
||||
** Texture
|
||||
*/
|
||||
|
||||
#ifndef TEXTURE_HPP_
|
||||
#define TEXTURE_HPP_
|
||||
|
||||
#include <raylib.h>
|
||||
#include <string>
|
||||
#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_ */
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2021
|
||||
** Bomberman
|
||||
** File description:
|
||||
** Font
|
||||
*/
|
||||
|
||||
#ifndef FONT_HPP_
|
||||
#define FONT_HPP_
|
||||
|
||||
#include <raylib.h>
|
||||
#include <string>
|
||||
|
||||
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
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user