made the entity position into a rectangle

This commit is contained in:
nosch
2025-08-31 03:32:14 +02:00
parent 0fbcf0ea99
commit b8f6238d31
2 changed files with 5 additions and 6 deletions
+3 -4
View File
@@ -5,10 +5,9 @@
#include <sys/types.h> #include <sys/types.h>
#include <iostream> #include <iostream>
Entity::Entity(ID Id, int x, int y, std::string &n, int h, int maxh) { Entity::Entity(ID Id, raylib::Rectangle Rect, std::string &n, int h, int maxh) {
id = Id; id = Id;
position.x = x; rect = Rect;
position.y = y;
health = h; health = h;
maxhealth = maxh; maxhealth = maxh;
nametag = n; nametag = n;
@@ -23,5 +22,5 @@ void Entity::Update() {
} }
void Entity::Draw() { void Entity::Draw() {
DrawTextureEx(entityTextures.GetTexture(id), position, 0, 0, WHITE); DrawTextureEx(entityTextures.GetTexture(id), raylib::Vector2(rect.x, rect.y), 0, 0, WHITE);
} }
+2 -2
View File
@@ -14,7 +14,7 @@ using ControllerFunc = std::function<void(Entity&)>;
struct Entity { struct Entity {
ID id; ID id;
raylib::Vector2 position; raylib::Rectangle rect;
int health; int health;
int maxhealth; int maxhealth;
std::string nametag; std::string nametag;
@@ -22,7 +22,7 @@ struct Entity {
void Update(); void Update();
void Draw(); void Draw();
Entity(ID Id, int x, int y, std::string &n, int h, int maxh); Entity(ID Id, raylib::Rectangle rect, std::string &n, int h, int maxh);
}; };