This commit is contained in:
2025-10-25 21:15:13 -05:00
parent 5c3db5d991
commit d74226dab1
4 changed files with 8 additions and 7 deletions

View File

@@ -25,6 +25,7 @@ void entityInit(entity_t *entity, const entitytype_t type) {
memoryZero(entity, sizeof(entity_t));
entity->id = (uint8_t)(entity - ENTITIES);
entity->type = type;
entity->hitboxRadius = .5f;
// Init. I did use a callback struct but it was not flexible enough.
switch(type) {
@@ -46,6 +47,7 @@ void entityUpdate(entity_t *entity) {
assertTrue(entity->type < ENTITY_TYPE_COUNT, "Invalid entity type");
assertTrue(entity->type != ENTITY_TYPE_NULL, "Cannot have NULL entity type");
//
if(entity->type == ENTITY_TYPE_PLAYER) {
playerMovement(entity);
}
@@ -67,15 +69,15 @@ void entityUpdate(entity_t *entity) {
// Our hitbox
physicscircle_t self;
glm_vec2_copy(entity->position, self.position);
self.radius = 0.5f;
self.radius = entity->hitboxRadius;
physicscircle_t other;
other.radius = self.radius;
// TODO: what if multiple collisions?
do {
if(start == entity) continue;
if(start->type == ENTITY_TYPE_NULL) continue;
other.radius = start->hitboxRadius;
glm_vec2_copy(start->position, other.position);
physicscirclecircleresult_t result;
@@ -90,7 +92,7 @@ void entityUpdate(entity_t *entity) {
// Friction (and dampening)
glm_vec3_muladds(
entity->velocity, -ENTITY_FRICTION * TIME.delta, entity->velocity
entity->velocity, -ENTITY_FRICTION * TIME.fixedDelta, entity->velocity
);
if(mathAbs(entity->velocity[0]) < ENTITY_MIN_VELOCITY) {