diff --git a/src/rpg/entity/entity.c b/src/rpg/entity/entity.c index 1fa3b44..86c8f3d 100644 --- a/src/rpg/entity/entity.c +++ b/src/rpg/entity/entity.c @@ -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) { diff --git a/src/rpg/entity/entity.h b/src/rpg/entity/entity.h index e44054c..9e53ae6 100644 --- a/src/rpg/entity/entity.h +++ b/src/rpg/entity/entity.h @@ -32,7 +32,6 @@ typedef struct entity_s { vec3 position; vec3 velocity; - vec2 hitbox; float_t hitboxRadius; union { diff --git a/src/rpg/entity/player.h b/src/rpg/entity/player.h index 1d165d0..13ee43b 100644 --- a/src/rpg/entity/player.h +++ b/src/rpg/entity/player.h @@ -8,8 +8,8 @@ #pragma once #include "dusk.h" -#define PLAYER_SPEED 32.0f -#define PLAYER_SPEED_RUNNING 64.0f +#define PLAYER_SPEED 48.0f +#define PLAYER_SPEED_RUNNING 72.0f #define PLAYER_INTERACTION_RANGE 1.0f #define PLAYER_INTERACTION_SIZE 0.5f diff --git a/src/time/time.c b/src/time/time.c index 6e84246..8882212 100644 --- a/src/time/time.c +++ b/src/time/time.c @@ -41,7 +41,7 @@ void timeUpdate(void) { TIME.time += TIME.delta; // Perform a fixed time step. - if(TIME.time - TIME.fixedTime >= TIME_STEP) { + if(TIME.time - TIME.fixedTime >= (TIME_STEP * 0.9f)) { TIME.fixedUpdate = true; TIME.fixedDelta = TIME_STEP; TIME.fixedTime += TIME_STEP;