feat: add rendering by transform instead of raw x and y
This commit is contained in:
parent
7f32a1d51b
commit
500672d06d
@ -1,8 +1,18 @@
|
|||||||
#include "sprite_component.h"
|
#include "sprite_component.h"
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
|
|
||||||
|
#include "Logger.h"
|
||||||
|
#include "transform_component.h"
|
||||||
|
|
||||||
|
|
||||||
void SpriteComponent::Render(float x, float y) const {
|
void SpriteComponent::Render(float x, float y) const {
|
||||||
if (texture) {
|
if (texture) {
|
||||||
DrawTexture(*reinterpret_cast<Texture2D*>(texture), x, y, WHITE);
|
DrawTexture(*reinterpret_cast<Texture2D*>(texture), x, y, WHITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpriteComponent::Render(TransformComponent transform) const {
|
||||||
|
if (texture) {
|
||||||
|
DrawTexture(*reinterpret_cast<Texture2D*>(texture), transform.x, transform.y, WHITE);
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "transform_component.h"
|
||||||
|
|
||||||
|
|
||||||
struct SpriteComponent {
|
struct SpriteComponent {
|
||||||
public:
|
public:
|
||||||
void* texture; // void* to abstract Texture2D
|
void* texture; // void* to abstract Texture2D
|
||||||
void Render(float x, float y) const;
|
void Render(float x, float y) const;
|
||||||
|
void Render(TransformComponent transform) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Usage:
|
// Usage:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user