mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-04 02:36:31 +00:00
more conversion operator to avoid extracting data methods
This commit is contained in:
@@ -77,7 +77,7 @@ namespace RAY
|
||||
return this->_color.a;
|
||||
}
|
||||
|
||||
const ::Color &Color::getColor(void) const
|
||||
RAY::Color::operator ::Color() const
|
||||
{
|
||||
return this->_color;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace RAY {
|
||||
unsigned char getA(void) const;
|
||||
|
||||
//! @return color struct
|
||||
const ::Color &getColor(void) const;
|
||||
operator ::Color() const;
|
||||
|
||||
//! @return hexadecimal value of color
|
||||
int toHex(void) const;
|
||||
|
||||
@@ -32,10 +32,10 @@ RAY::Drawables::Drawables2D::Circle &RAY::Drawables::Drawables2D::Circle::setRad
|
||||
|
||||
void RAY::Drawables::Drawables2D::Circle::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawCircleV(this->_position, this->_radius, this->_color.getColor());
|
||||
DrawCircleV(this->_position, this->_radius, this->_color);
|
||||
}
|
||||
|
||||
void RAY::Drawables::Drawables2D::Circle::drawOn(RAY::Image &image)
|
||||
{
|
||||
ImageDrawCircleV(&(image.getImage()), this->_position, this->_radius, this->_color.getColor());
|
||||
ImageDrawCircleV(image, this->_position, this->_radius, this->_color);
|
||||
}
|
||||
@@ -34,10 +34,10 @@ RAY::Drawables::Drawables2D::Line &RAY::Drawables::Drawables2D::Line::setEndPosi
|
||||
|
||||
void RAY::Drawables::Drawables2D::Line::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawLineV(this->_position, this->_end, this->_color.getColor());
|
||||
DrawLineV(this->_position, this->_end, this->_color);
|
||||
}
|
||||
|
||||
void RAY::Drawables::Drawables2D::Line::drawOn(RAY::Image &image)
|
||||
{
|
||||
ImageDrawLineV(&(image.getImage()), this->_position, this->_end, this->_color.getColor());
|
||||
ImageDrawLineV(image, this->_position, this->_end, this->_color);
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ RAY::Drawables::Drawables2D::Point::Point(int x, int y, const Color &color):
|
||||
|
||||
void RAY::Drawables::Drawables2D::Point::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawPixel(this->_position.x, this->_position.y, this->_color.getColor());
|
||||
DrawPixel(this->_position.x, this->_position.y, this->_color);
|
||||
}
|
||||
|
||||
void RAY::Drawables::Drawables2D::Point::drawOn(RAY::Image &image)
|
||||
{
|
||||
ImageDrawPixel(&(image.getImage()), this->_position.x, this->_position.y, this->_color.getColor());
|
||||
ImageDrawPixel(image, this->_position.x, this->_position.y, this->_color);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,10 +40,10 @@ RAY::Drawables::Drawables2D::Rectangle &RAY::Drawables::Drawables2D::Rectangle::
|
||||
|
||||
void RAY::Drawables::Drawables2D::Rectangle::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawRectangleV(this->_position, this->_dimensions, this->_color.getColor());
|
||||
DrawRectangleV(this->_position, this->_dimensions, this->_color);
|
||||
}
|
||||
|
||||
void RAY::Drawables::Drawables2D::Rectangle::drawOn(RAY::Image &image)
|
||||
{
|
||||
ImageDrawRectangleV(&(image.getImage()), this->_position, this->_dimensions, this->_color.getColor());
|
||||
ImageDrawRectangleV(image, this->_position, this->_dimensions, this->_color);
|
||||
}
|
||||
|
||||
@@ -62,18 +62,18 @@ void RAY::Drawables::Drawables2D::Text::drawOn(RAY::Window &)
|
||||
{
|
||||
if (!this->_font.recs)
|
||||
DrawText(this->_text.c_str(), this->_position.x, this->_position.y,
|
||||
this->_size, this->_color.getColor());
|
||||
this->_size, this->_color);
|
||||
else
|
||||
DrawTextEx(this->_font, this->_text.c_str(), this->_position,
|
||||
this->_size, this->_spacing, this->_color.getColor());
|
||||
this->_size, this->_spacing, this->_color);
|
||||
}
|
||||
|
||||
void RAY::Drawables::Drawables2D::Text::drawOn(RAY::Image &image)
|
||||
{
|
||||
if (!this->_font.recs)
|
||||
ImageDrawText(&(image.getImage()), this->_text.c_str(), this->_position.x, this->_position.y,
|
||||
this->_size, this->_color.getColor());
|
||||
ImageDrawText(image, this->_text.c_str(), this->_position.x, this->_position.y,
|
||||
this->_size, this->_color);
|
||||
else
|
||||
ImageDrawTextEx(&(image.getImage()), this->_font, this->_text.c_str(), this->_position,
|
||||
this->_size, this->_spacing, this->_color.getColor());
|
||||
ImageDrawTextEx(image, this->_font, this->_text.c_str(), this->_position,
|
||||
this->_size, this->_spacing, this->_color);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ RAY::Drawables::Drawables2D::Triangle &RAY::Drawables::Drawables2D::Triangle::se
|
||||
|
||||
void RAY::Drawables::Drawables2D::Triangle::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawTriangle(this->_position, this->_posB, this->_posC, this->_color.getColor());
|
||||
DrawTriangle(this->_position, this->_posB, this->_posC, this->_color);
|
||||
}
|
||||
|
||||
void RAY::Drawables::Drawables2D::Triangle::drawOn(RAY::Image &image)
|
||||
|
||||
@@ -33,5 +33,5 @@ const RAY::Vector3 &RAY::Drawables::Drawables3D::Circle::getCenterPos(void) cons
|
||||
void RAY::Drawables::Drawables3D::Circle::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawCircle3D(this->_centerPos, this->_radius,this->_rotationAxis,
|
||||
this->_rotationAngle, this->_color.getColor());
|
||||
this->_rotationAngle, this->_color);
|
||||
}
|
||||
|
||||
@@ -38,5 +38,5 @@ RAY::Drawables::Drawables3D::Cube &RAY::Drawables::Drawables3D::Cube::setPositio
|
||||
|
||||
void RAY::Drawables::Drawables3D::Cube::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawCubeV(this->_position, this->_dimenstions, this->_color.getColor());
|
||||
DrawCubeV(this->_position, this->_dimenstions, this->_color);
|
||||
}
|
||||
|
||||
@@ -62,5 +62,5 @@ RAY::Drawables::Drawables3D::Cylinder &RAY::Drawables::Drawables3D::Cylinder::se
|
||||
|
||||
void RAY::Drawables::Drawables3D::Cylinder::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawCylinder(this->_centerPos, this->_topRadius, this->_bottomRadius, this->_height, 0, this->_color.getColor());
|
||||
DrawCylinder(this->_centerPos, this->_topRadius, this->_bottomRadius, this->_height, 0, this->_color);
|
||||
}
|
||||
|
||||
@@ -37,5 +37,5 @@ RAY::Drawables::Drawables3D::Line &RAY::Drawables::Drawables3D::Line::setEndPosi
|
||||
|
||||
void RAY::Drawables::Drawables3D::Line::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawLine3D(this->_startPosition, this->_endPosition, this->_color.getColor());
|
||||
DrawLine3D(this->_startPosition, this->_endPosition, this->_color);
|
||||
}
|
||||
|
||||
@@ -37,5 +37,5 @@ RAY::Drawables::Drawables3D::Plane &RAY::Drawables::Drawables3D::Plane::setDimen
|
||||
|
||||
void RAY::Drawables::Drawables3D::Plane::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawPlane(this->_position, this->_dimensions, this->_color.getColor());
|
||||
DrawPlane(this->_position, this->_dimensions, this->_color);
|
||||
}
|
||||
|
||||
@@ -27,5 +27,5 @@ RAY::Drawables::Drawables3D::Point &RAY::Drawables::Drawables3D::Point::setPosit
|
||||
|
||||
void RAY::Drawables::Drawables3D::Point::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawPoint3D(this->_position, this->_color.getColor());
|
||||
DrawPoint3D(this->_position, this->_color);
|
||||
}
|
||||
|
||||
@@ -37,5 +37,5 @@ RAY::Drawables::Drawables3D::Ray &RAY::Drawables::Drawables3D::Ray::setDirection
|
||||
|
||||
void RAY::Drawables::Drawables3D::Ray::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawRay(this->_ray, this->_color.getColor());
|
||||
DrawRay(this->_ray, this->_color);
|
||||
}
|
||||
@@ -37,5 +37,5 @@ RAY::Drawables::Drawables3D::Sphere &RAY::Drawables::Drawables3D::Sphere::setRad
|
||||
|
||||
void RAY::Drawables::Drawables3D::Sphere::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawSphere(this->_centerPos, this->_radius, this->_color.getColor());
|
||||
DrawSphere(this->_centerPos, this->_radius, this->_color);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ RAY::Drawables::Drawables3D::Triangle &RAY::Drawables::Drawables3D::Triangle::se
|
||||
|
||||
void RAY::Drawables::Drawables3D::Triangle::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawTriangle3D(this->_posA, this->_posB, this->_posC, this->_color.getColor());
|
||||
DrawTriangle3D(this->_posA, this->_posB, this->_posC, this->_color);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,12 @@ RAY::Image::Image()
|
||||
|
||||
}
|
||||
|
||||
RAY::Image::Image(RAY::Texture &texture):
|
||||
_image(GetTextureData(texture))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RAY::Image::~Image()
|
||||
{
|
||||
UnloadImage(_image);
|
||||
@@ -40,7 +46,12 @@ bool RAY::Image::unload()
|
||||
return true;
|
||||
}
|
||||
|
||||
::Image &RAY::Image::getImage(void)
|
||||
RAY::Image::operator ::Image() const
|
||||
{
|
||||
return _image;
|
||||
}
|
||||
|
||||
RAY::Image::operator ::Image *()
|
||||
{
|
||||
return &this->_image;
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <raylib.h>
|
||||
#include <string>
|
||||
#include "Canvas.hpp"
|
||||
#include "Texture.hpp"
|
||||
#include "IRessource.hpp"
|
||||
|
||||
namespace RAY
|
||||
@@ -25,6 +26,10 @@ namespace RAY
|
||||
//! @param filename: path to file to load
|
||||
Image(const std::string &filename);
|
||||
|
||||
//! @brief Create an image, using data from a texure
|
||||
//! @param texture: texture to extract data from
|
||||
Image(Texture &texture);
|
||||
|
||||
//! @brief A default copy constructor
|
||||
Image(const Image &image) = default;
|
||||
|
||||
@@ -49,7 +54,8 @@ namespace RAY
|
||||
bool unload() override;
|
||||
|
||||
//! @brief get image
|
||||
::Image &getImage(void);
|
||||
operator ::Image() const;
|
||||
operator ::Image *();
|
||||
|
||||
//! @brief draw drawable
|
||||
void draw(Drawables::ADrawable2D &);
|
||||
|
||||
@@ -40,12 +40,7 @@ bool RAY::Texture::unload()
|
||||
return true;
|
||||
}
|
||||
|
||||
Image RAY::Texture::toImage(void) const
|
||||
{
|
||||
return GetTextureData(_texture);
|
||||
}
|
||||
|
||||
const ::Texture &RAY::Texture::getTexture(void) const
|
||||
RAY::Texture::operator ::Texture() const
|
||||
{
|
||||
return this->_texture;
|
||||
}
|
||||
|
||||
@@ -44,11 +44,8 @@ namespace RAY
|
||||
//! @brief unload ressources
|
||||
bool unload() override;
|
||||
|
||||
//! @brief get image
|
||||
::Image toImage(void) const;
|
||||
|
||||
//! @return libray Texture struct
|
||||
const ::Texture &getTexture(void) const;
|
||||
operator ::Texture() const;
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
@@ -90,7 +90,7 @@ void RAY::Window::setFPS(unsigned int fps)
|
||||
|
||||
void RAY::Window::clear(const RAY::Color &color)
|
||||
{
|
||||
ClearBackground(color.getColor());
|
||||
ClearBackground(color);
|
||||
}
|
||||
|
||||
void RAY::Window::beginDrawing(void)
|
||||
@@ -135,7 +135,7 @@ void RAY::Window::draw(RAY::Drawables::IDrawable &drawable)
|
||||
|
||||
void RAY::Window::draw(const RAY::Texture &texture, const Vector2 &position, const Color &tint)
|
||||
{
|
||||
DrawTexture(texture.getTexture(), position.x, position.y, tint.getColor());
|
||||
DrawTexture(texture, position.x, position.y, tint);
|
||||
}
|
||||
|
||||
void RAY::Window::draw(const Mesh &mesh, const Material &material, const Matrix &transform)
|
||||
@@ -145,5 +145,5 @@ void RAY::Window::draw(const Mesh &mesh, const Material &material, const Matrix
|
||||
|
||||
void RAY::Window::setIcon(RAY::Image &img)
|
||||
{
|
||||
SetWindowIcon(img.getImage());
|
||||
SetWindowIcon(img);
|
||||
}
|
||||
@@ -24,7 +24,7 @@ namespace WAL
|
||||
//! @return The manager instance used to call this function is returned. This allow method chaining.
|
||||
SceneManager &addBackScene(Scene &&scene);
|
||||
|
||||
//! @breif Get the current scene
|
||||
//! @brief Get the current scene
|
||||
Scene &getCurrent();
|
||||
|
||||
//! @brief Remove the current scene and switch to the previous scene on the stack.
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
** Vector
|
||||
*/
|
||||
|
||||
#include "Vector.hpp"
|
||||
#include "Vector/Vector3.hpp"
|
||||
#include "Models/Vector3.hpp"
|
||||
|
||||
RAY::Vector3 toRAY(const WAL::Vector3<float> &wal)
|
||||
RAY::Vector3 toRAY(const WAL::Vector3f &wal)
|
||||
{
|
||||
return (RAY::Vector3){wal.x, wal.y, wal.y};
|
||||
return RAY::Vector3(wal.x, wal.y, wal.y);
|
||||
}
|
||||
Reference in New Issue
Block a user