restructured everything
This commit is contained in:
parent
4225a524b9
commit
c66cae17f2
61 changed files with 18406 additions and 1710 deletions
94
src/graphics/drawable/Transformable.cpp
Normal file
94
src/graphics/drawable/Transformable.cpp
Normal file
|
@ -0,0 +1,94 @@
|
|||
#include "graphics/drawable/Transformable.hpp"
|
||||
|
||||
SDLU_BEGIN
|
||||
Transformable::Transformable() :
|
||||
position(0, 0), origin(0, 0),
|
||||
scale(1.f, 1.f), rotation(0.f)
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
Transformable::~Transformable()
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
Vector2f Transformable::GetPosition()
|
||||
{
|
||||
return position;
|
||||
}
|
||||
|
||||
void Transformable::SetPosition(const Vector2f& position)
|
||||
{
|
||||
this->position = position;
|
||||
}
|
||||
|
||||
void Transformable::SetPosition(float x, float y)
|
||||
{
|
||||
position = Vector2f(x, y);
|
||||
}
|
||||
|
||||
void Transformable::Move(const Vector2f& position)
|
||||
{
|
||||
this->position += position;
|
||||
}
|
||||
|
||||
void Transformable::Move(float x, float y)
|
||||
{
|
||||
position += Vector2f(x, y);
|
||||
}
|
||||
Vector2f Transformable::GetOrigin()
|
||||
{
|
||||
return origin;
|
||||
}
|
||||
|
||||
void Transformable::SetOrigin(const Vector2f& origin)
|
||||
{
|
||||
this->origin = origin;
|
||||
}
|
||||
|
||||
void Transformable::SetOrigin(float x, float y)
|
||||
{
|
||||
origin = Vector2f(x, y);
|
||||
}
|
||||
|
||||
Vector2f Transformable::GetScale()
|
||||
{
|
||||
return scale;
|
||||
}
|
||||
|
||||
void Transformable::SetScale(const Vector2f& scale)
|
||||
{
|
||||
this->scale = scale;
|
||||
}
|
||||
|
||||
void Transformable::SetScale(float x, float y)
|
||||
{
|
||||
scale = Vector2f(x, y);
|
||||
}
|
||||
|
||||
void Transformable::Scale(const Vector2f& scale)
|
||||
{
|
||||
this->scale += scale;
|
||||
}
|
||||
|
||||
void Transformable::Scale(float x, float y)
|
||||
{
|
||||
scale += Vector2f(x, y);
|
||||
}
|
||||
|
||||
float Transformable::GetRotation()
|
||||
{
|
||||
return rotation;
|
||||
}
|
||||
|
||||
void Transformable::SetRotation(float angle)
|
||||
{
|
||||
rotation = angle;
|
||||
}
|
||||
|
||||
void Transformable::Rotate(float angle)
|
||||
{
|
||||
rotation += angle;
|
||||
}
|
||||
SDLU_END
|
45
src/graphics/drawable/shapes/Rectangle.cpp
Normal file
45
src/graphics/drawable/shapes/Rectangle.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include <graphics/drawable/shapes/Rectangle.hpp>
|
||||
#include <graphics/RenderTarget.hpp>
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
namespace sdlu
|
||||
{
|
||||
Rectangle::Rectangle() :
|
||||
Shape()
|
||||
{
|
||||
}
|
||||
|
||||
Rectangle::Rectangle(const Vector2f& position, const Vector2f& size) :
|
||||
Shape()
|
||||
{
|
||||
this->position = position;
|
||||
this->size = size;
|
||||
}
|
||||
|
||||
Vector2f Rectangle::GetSize()
|
||||
{
|
||||
return this->size;
|
||||
}
|
||||
|
||||
void Rectangle::SetSize(const Vector2f& size)
|
||||
{
|
||||
this->size = size;
|
||||
}
|
||||
|
||||
void Rectangle::SetSize(float x, float y)
|
||||
{
|
||||
this->size = Vector2f(x, y);
|
||||
}
|
||||
|
||||
void Rectangle::Draw(SDL_Renderer* const renderer) const
|
||||
{
|
||||
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a);
|
||||
SDL_Rect rect;
|
||||
rect.x = position.x;
|
||||
rect.y = position.y;
|
||||
rect.w = size.x;
|
||||
rect.h = size.y;
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
}
|
||||
}
|
23
src/graphics/drawable/shapes/Shape.cpp
Normal file
23
src/graphics/drawable/shapes/Shape.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <graphics/drawable/shapes/Shape.hpp>
|
||||
|
||||
namespace sdlu
|
||||
{
|
||||
Shape::~Shape()
|
||||
{
|
||||
}
|
||||
|
||||
void Shape::SetColor(const Color& color)
|
||||
{
|
||||
this->color = color;
|
||||
}
|
||||
|
||||
Color Shape::GetColor()
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
Shape::Shape() :
|
||||
Drawable(), Transformable()
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue