Fuck
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -21,6 +21,7 @@ typedef struct entity_s {
|
||||
// Movement
|
||||
entitydir_t direction;
|
||||
worldpos_t position;
|
||||
tilepos_t subPosition;
|
||||
worldpos_t lastPosition;
|
||||
|
||||
entityanim_t animation;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -15,4 +15,11 @@ typedef enum {
|
||||
ENTITY_ANIM_IDLE,
|
||||
ENTITY_ANIM_TURN,
|
||||
ENTITY_ANIM_WALK,
|
||||
} entityanim_t;
|
||||
} entityanim_t;
|
||||
|
||||
/**
|
||||
* Updates the entity's animation state.
|
||||
*
|
||||
* @param entity Pointer to the entity to update.
|
||||
*/
|
||||
void entityAnimUpdate(entity_t *entity);
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user