From 857c6b3d476a68f62e4044b23f972e93b0b37ca8 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Tue, 16 Jun 2026 09:18:13 -0500 Subject: [PATCH] Fuck --- src/dusk/rpg/entity/entity.c | 12 ++---------- src/dusk/rpg/entity/entity.h | 1 + src/dusk/rpg/entity/entityanim.c | 12 +++++++++++- src/dusk/rpg/entity/entityanim.h | 9 ++++++++- src/dusk/rpg/overworld/worldpos.h | 2 ++ src/dusk/scene/overworld/sceneoverworld.c | 10 ++++------ 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/dusk/rpg/entity/entity.c b/src/dusk/rpg/entity/entity.c index 4b8c0ffa..98052149 100644 --- a/src/dusk/rpg/entity/entity.c +++ b/src/dusk/rpg/entity/entity.c @@ -38,15 +38,7 @@ void entityUpdate(entity_t *entity) { assertTrue(entity->type != ENTITY_TYPE_NULL, "Cannot have NULL entity type"); // What state is the entity in? - if(entity->animation != ENTITY_ANIM_IDLE) { - // Entity is mid animation, tick it (down). - entity->animTime -= TIME.delta; - if(entity->animTime <= 0) { - entity->animation = ENTITY_ANIM_IDLE; - entity->animTime = 0; - } - return; - } + entityAnimUpdate(entity); // Movement code. if( @@ -69,8 +61,8 @@ void entityWalk(entity_t *entity, const entitydir_t direction) { // Where are we moving? worldpos_t newPos = entity->position; + worldunits_t relX, relY; { - worldunits_t relX, relY; entityDirGetRelative(direction, &relX, &relY); newPos.x += relX; newPos.y += relY; diff --git a/src/dusk/rpg/entity/entity.h b/src/dusk/rpg/entity/entity.h index 258b54f2..e6a93b5c 100644 --- a/src/dusk/rpg/entity/entity.h +++ b/src/dusk/rpg/entity/entity.h @@ -21,6 +21,7 @@ typedef struct entity_s { // Movement entitydir_t direction; worldpos_t position; + tilepos_t subPosition; worldpos_t lastPosition; entityanim_t animation; diff --git a/src/dusk/rpg/entity/entityanim.c b/src/dusk/rpg/entity/entityanim.c index d5730f3f..d5024815 100644 --- a/src/dusk/rpg/entity/entityanim.c +++ b/src/dusk/rpg/entity/entityanim.c @@ -5,5 +5,15 @@ * https://opensource.org/licenses/MIT */ -#include "entityanim.h" +#include "entity.h" +#include "time/time.h" +void entityAnimUpdate(entity_t *entity) { + if(entity->animation == ENTITY_ANIM_IDLE) return; + + entity->animTime -= TIME.delta; + if(entity->animTime <= 0) { + entity->animation = ENTITY_ANIM_IDLE; + entity->animTime = 0; + } +} \ No newline at end of file diff --git a/src/dusk/rpg/entity/entityanim.h b/src/dusk/rpg/entity/entityanim.h index 42f7d40a..cb040070 100644 --- a/src/dusk/rpg/entity/entityanim.h +++ b/src/dusk/rpg/entity/entityanim.h @@ -15,4 +15,11 @@ typedef enum { ENTITY_ANIM_IDLE, ENTITY_ANIM_TURN, ENTITY_ANIM_WALK, -} entityanim_t; \ No newline at end of file +} entityanim_t; + +/** + * Updates the entity's animation state. + * + * @param entity Pointer to the entity to update. + */ +void entityAnimUpdate(entity_t *entity); \ No newline at end of file diff --git a/src/dusk/rpg/overworld/worldpos.h b/src/dusk/rpg/overworld/worldpos.h index 8a5d74c7..829a1a67 100644 --- a/src/dusk/rpg/overworld/worldpos.h +++ b/src/dusk/rpg/overworld/worldpos.h @@ -29,6 +29,8 @@ typedef uint32_t chunktileindex_t; typedef int32_t worldunits_t; typedef int32_t chunkunits_t; +typedef int8_t tileunit_t; + typedef struct worldpos_s { worldunit_t x, y, z; } worldpos_t; diff --git a/src/dusk/scene/overworld/sceneoverworld.c b/src/dusk/scene/overworld/sceneoverworld.c index f5a7f778..05a42237 100644 --- a/src/dusk/scene/overworld/sceneoverworld.c +++ b/src/dusk/scene/overworld/sceneoverworld.c @@ -41,8 +41,6 @@ errorret_t sceneOverworldRender(scenedata_t *sceneData) { errorChain(shaderBind(&SHADER_UNLIT)); - errorChain(shaderSetTexture(&SHADER_UNLIT, SHADER_UNLIT_TEXTURE, &TEXTURE_TEST)); - errorChain(shaderSetColor(&SHADER_UNLIT, SHADER_UNLIT_COLOR, COLOR_WHITE)); // Model glm_mat4_identity(model); @@ -85,7 +83,7 @@ errorret_t sceneOverworldRender(scenedata_t *sceneData) { ); errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_VIEW, eye)); - // Chunk Data + // Chunks { shadermaterial_t chunkMaterial = { .unlit = { @@ -122,9 +120,9 @@ errorret_t sceneOverworldRender(scenedata_t *sceneData) { if(ent->type == ENTITY_TYPE_NULL) continue; vec3 position = { - ent->position.x, - ent->position.y, - ((float_t)ent->position.z) + 0.01f + ent->position.x + ((float_t)ent->subPosition.x / TILE_POS_MAX), + ent->position.y + ((float_t)ent->subPosition.y / TILE_POS_MAX), + ent->position.z + ((float_t)ent->subPosition.z / TILE_POS_MAX) + 0.01f }; glm_vec3_copy(position, sprites[spriteCount].min);