const const const const qualify!!!!

This commit is contained in:
2025-01-08 23:30:14 -05:00
parent 4ecddafcd5
commit d26237762e
10 changed files with 87 additions and 35 deletions

View File

@@ -19,6 +19,7 @@ private:
bool destroying = false;
bool last_rendered_to_window = false;
float render_target_frame_delta = 0;
unsigned long last_tick_time = 0;
protected:
// 25ms.
u8 tick_rate = 40;
@@ -42,6 +43,8 @@ public:
[[nodiscard]] bool ShouldTick() const;
[[nodiscard]] float TickDeltaTime() const;
[[nodiscard]] float FrameDeltaTime() const;
/// @returns the number of microseconds since Jan 1st 1970 that the last tick was finished on.
[[nodiscard]] unsigned long LastTickTime() const;
public:
void ShouldTick(bool state);
void SetActiveCamera(Camera* camera) { active_camera = camera; };

View File

@@ -12,8 +12,8 @@ private:
public:
[[nodiscard]] std::string GetTextureFilesystemPath() const { return texture_path; }
[[nodiscard]] std::string GetAlphaMaskFilesystemPath() const { return alpha_mask_path; }
[[nodiscard]] Texture* GetTexture() override;
[[nodiscard]] Texture* GetAlphaMask() override;
[[nodiscard]] Texture* GetTexture() const override;
[[nodiscard]] Texture* GetAlphaMask() const override;
public:
/** The Texture *must* be instanced. The alpha-mask *can* be instanced.
* You can use SetAlphaMask() to change to a unique one.
@@ -23,7 +23,7 @@ public:
*/
~InstancedSprite() override;
InstancedSprite(const Vector2& position, unsigned int layer, const std::string& instanced_texture_filesystem_path,
float face_angle = 0.0f, const Color4& base_color = Colors::White, Texture* unique_alpha_mask = nullptr, const std::string& instanced_alpha_mask_filesystem_path = "")
: Sprite(position, layer, face_angle, base_color, nullptr, unique_alpha_mask), texture_path(instanced_texture_filesystem_path),
const Vector2& origin = {0, 0}, float face_angle = 0.0f, const Color4& base_color = Colors::White, Texture* unique_alpha_mask = nullptr, const std::string& instanced_alpha_mask_filesystem_path = "")
: Sprite(position, origin, layer, face_angle, base_color, nullptr, unique_alpha_mask), texture_path(instanced_texture_filesystem_path),
alpha_mask_path(instanced_alpha_mask_filesystem_path) {}
};

View File

@@ -19,16 +19,23 @@ private:
protected:
Vector2 scale = {1, 1};
// Local space, Where the face_angle rotation should be preformed about.
// In local space, Where on the texture the entities "position" is.
// Also, this is where rotations will be done about by default.
// TODO separate.
Vector2 origin = {0, 0};
Color4 base_color = Colors::White;
protected:
[[nodiscard]] virtual Texture* GetTexture();
[[nodiscard]] virtual Texture* GetAlphaMask();
[[nodiscard]] Vector2 GetRenderPosition() const;
[[nodiscard]] Vector2 GetLocalSpaceOrigin() const;
[[nodiscard]] virtual Texture* GetTexture() const;
[[nodiscard]] virtual Texture* GetAlphaMask() const;
protected:
void SetAlphaMask(Texture* new_alpha_mask);
void SetOrigin(const Vector2& new_origin);
public:
void Render() override;
public:
~Sprite() override;
explicit Sprite(const Vector2& pos, unsigned int layer = 0, const float face_angle = 0.0f, const Color4& base_color = Colors::White, Texture* texture = nullptr,
Texture* alpha_mask = nullptr) : Renderable(layer), Movable(pos, face_angle), texture(texture), alpha_mask(alpha_mask), base_color(base_color) {}
explicit Sprite(const Vector2& pos, const Vector2& origin = {0, 0}, unsigned int layer = 0, const float face_angle = 0.0f, const Color4& base_color = Colors::White, Texture* texture = nullptr,
Texture* alpha_mask = nullptr) : Renderable(layer), Movable(pos, face_angle), texture(texture), alpha_mask(alpha_mask), base_color(base_color), origin(origin) {}
};