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");
|
assertTrue(entity->type != ENTITY_TYPE_NULL, "Cannot have NULL entity type");
|
||||||
|
|
||||||
// What state is the entity in?
|
// What state is the entity in?
|
||||||
if(entity->animation != ENTITY_ANIM_IDLE) {
|
entityAnimUpdate(entity);
|
||||||
// Entity is mid animation, tick it (down).
|
|
||||||
entity->animTime -= TIME.delta;
|
|
||||||
if(entity->animTime <= 0) {
|
|
||||||
entity->animation = ENTITY_ANIM_IDLE;
|
|
||||||
entity->animTime = 0;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Movement code.
|
// Movement code.
|
||||||
if(
|
if(
|
||||||
@@ -69,8 +61,8 @@ void entityWalk(entity_t *entity, const entitydir_t direction) {
|
|||||||
|
|
||||||
// Where are we moving?
|
// Where are we moving?
|
||||||
worldpos_t newPos = entity->position;
|
worldpos_t newPos = entity->position;
|
||||||
|
worldunits_t relX, relY;
|
||||||
{
|
{
|
||||||
worldunits_t relX, relY;
|
|
||||||
entityDirGetRelative(direction, &relX, &relY);
|
entityDirGetRelative(direction, &relX, &relY);
|
||||||
newPos.x += relX;
|
newPos.x += relX;
|
||||||
newPos.y += relY;
|
newPos.y += relY;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ typedef struct entity_s {
|
|||||||
// Movement
|
// Movement
|
||||||
entitydir_t direction;
|
entitydir_t direction;
|
||||||
worldpos_t position;
|
worldpos_t position;
|
||||||
|
tilepos_t subPosition;
|
||||||
worldpos_t lastPosition;
|
worldpos_t lastPosition;
|
||||||
|
|
||||||
entityanim_t animation;
|
entityanim_t animation;
|
||||||
|
|||||||
@@ -5,5 +5,15 @@
|
|||||||
* https://opensource.org/licenses/MIT
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,3 +16,10 @@ typedef enum {
|
|||||||
ENTITY_ANIM_TURN,
|
ENTITY_ANIM_TURN,
|
||||||
ENTITY_ANIM_WALK,
|
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 worldunits_t;
|
||||||
typedef int32_t chunkunits_t;
|
typedef int32_t chunkunits_t;
|
||||||
|
|
||||||
|
typedef int8_t tileunit_t;
|
||||||
|
|
||||||
typedef struct worldpos_s {
|
typedef struct worldpos_s {
|
||||||
worldunit_t x, y, z;
|
worldunit_t x, y, z;
|
||||||
} worldpos_t;
|
} worldpos_t;
|
||||||
|
|||||||
@@ -41,8 +41,6 @@ errorret_t sceneOverworldRender(scenedata_t *sceneData) {
|
|||||||
|
|
||||||
|
|
||||||
errorChain(shaderBind(&SHADER_UNLIT));
|
errorChain(shaderBind(&SHADER_UNLIT));
|
||||||
errorChain(shaderSetTexture(&SHADER_UNLIT, SHADER_UNLIT_TEXTURE, &TEXTURE_TEST));
|
|
||||||
errorChain(shaderSetColor(&SHADER_UNLIT, SHADER_UNLIT_COLOR, COLOR_WHITE));
|
|
||||||
|
|
||||||
// Model
|
// Model
|
||||||
glm_mat4_identity(model);
|
glm_mat4_identity(model);
|
||||||
@@ -85,7 +83,7 @@ errorret_t sceneOverworldRender(scenedata_t *sceneData) {
|
|||||||
);
|
);
|
||||||
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_VIEW, eye));
|
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_VIEW, eye));
|
||||||
|
|
||||||
// Chunk Data
|
// Chunks
|
||||||
{
|
{
|
||||||
shadermaterial_t chunkMaterial = {
|
shadermaterial_t chunkMaterial = {
|
||||||
.unlit = {
|
.unlit = {
|
||||||
@@ -122,9 +120,9 @@ errorret_t sceneOverworldRender(scenedata_t *sceneData) {
|
|||||||
if(ent->type == ENTITY_TYPE_NULL) continue;
|
if(ent->type == ENTITY_TYPE_NULL) continue;
|
||||||
|
|
||||||
vec3 position = {
|
vec3 position = {
|
||||||
ent->position.x,
|
ent->position.x + ((float_t)ent->subPosition.x / TILE_POS_MAX),
|
||||||
ent->position.y,
|
ent->position.y + ((float_t)ent->subPosition.y / TILE_POS_MAX),
|
||||||
((float_t)ent->position.z) + 0.01f
|
ent->position.z + ((float_t)ent->subPosition.z / TILE_POS_MAX) + 0.01f
|
||||||
};
|
};
|
||||||
|
|
||||||
glm_vec3_copy(position, sprites[spriteCount].min);
|
glm_vec3_copy(position, sprites[spriteCount].min);
|
||||||
|
|||||||
Reference in New Issue
Block a user