Sprites
This commit is contained in:
@@ -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);
|
||||
|
||||
|
@@ -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) {}
|
||||
};
|
30
include/Engine/Entity/Sprite.h
Normal file
30
include/Engine/Entity/Sprite.h
Normal 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) {}
|
||||
};
|
@@ -4,6 +4,7 @@
|
||||
#include <Engine/Entity/Renderable.h>
|
||||
#include <Engine/Entity/Hud.h>
|
||||
#include <Engine/Level/Fixed.h>
|
||||
#include <JGL/types/RenderTarget.h>
|
||||
|
||||
namespace Engine {
|
||||
class Scene;
|
||||
@@ -36,7 +37,7 @@ public:
|
||||
virtual void Unload();
|
||||
virtual void Init() {}
|
||||
virtual void Update();
|
||||
virtual void Render();
|
||||
virtual void Render(RenderTarget* render_target = nullptr);
|
||||
public:
|
||||
explicit Scene(const std::string& name) : name(name) {}
|
||||
virtual ~Scene();
|
||||
|
@@ -11,6 +11,6 @@ public:
|
||||
|
||||
void Init() final;
|
||||
void Update() final;
|
||||
void Render() final;
|
||||
void Render(RenderTarget* render_target = nullptr) final;
|
||||
~LoadingScreen() final;
|
||||
};
|
||||
|
Reference in New Issue
Block a user