made the player a Entity and gave it a controller

This commit is contained in:
nosch
2025-08-31 16:36:03 +02:00
parent 84cd82c8c0
commit 9f1374c0b1
6 changed files with 65 additions and 35 deletions
+10 -4
View File
@@ -5,22 +5,28 @@
#include <sys/types.h>
#include <iostream>
Entity::Entity(ID Id, raylib::Rectangle Rect, std::string &n, int h, int maxh) {
void emptycontroller (Entity &e, float deltatime) {
std::cout << "doing no shit cuz funny lmao";
}
Entity::Entity(ID Id, raylib::Rectangle Rect,std::string n, int h, int maxh) {
id = Id;
spriteid = 0;
rect = Rect;
health = h;
maxhealth = maxh;
nametag = n;
controller = emptycontroller;
}
void Entity::Update() {
void Entity::Update(float deltatime) {
if (controller) {
controller(*this);
controller(*this, deltatime);
}else {
std::cout << "Entity is missing an controller, doing nothing.\n";
}
}
void Entity::Draw() {
DrawTextureEx(entityTextures.GetTexture(id), raylib::Vector2(rect.x, rect.y), 0, 0, WHITE);
DrawTextureEx(entityTextures.GetTexture(spriteid), raylib::Vector2(rect.x, rect.y), 0, 0, WHITE);
}