This commit is contained in:
2025-01-02 15:17:14 -05:00
parent 18072f3b66
commit bd72263944
12 changed files with 72 additions and 17 deletions

View File

@@ -24,6 +24,8 @@ public:
void MoveLeft(float speed);
void MoveRight(float speed);
void Move(float angle_rad, float speed);
void Rotate(float speed);
void SetRotation(float new_rotation);

View File

@@ -9,7 +9,8 @@ namespace Engine {
class Engine::Renderable : public Entity {
public:
virtual void Render() {}
// *must* be overridden.
virtual void Render() = 0;
public:
explicit Renderable(const Vector2& position, float rotation = 0.0f) : Entity(position, rotation) {}
};

View File

@@ -0,0 +1,30 @@
#pragma once
#include <Engine/Entity/Renderable.h>
#include <JGL/types/Texture.h>
#include <J3ML/Geometry/AABB2D.hpp>
namespace Engine {
class Sprite;
}
class Engine::Sprite : public Renderable {
protected:
Texture* texture = nullptr;
// Positive alpha mask.
Texture* alpha_mask = nullptr;
Vector2 scale = {1, 1};
// Local space, Where the face_angle rotation should be preformed about.
Vector2 origin = {0, 0};
Color4 base_color = Colors::White;
public:
[[nodiscard]] Texture* GetTexture();
// World space.
[[nodiscard]] virtual AABB2D GetBounds();
public:
void Render() override;
public:
~Sprite() override;
explicit Sprite(const Vector2& pos, const float face_angle = 0.0f, const Color4& base_color = Colors::White, Texture* texture = nullptr,
Texture* alpha_mask = nullptr) : Renderable(pos, face_angle), texture(texture), alpha_mask(alpha_mask), base_color(base_color) {}
};