diff --git a/src/dawn/rpg/cutscene/cutscene.h b/src/dawn/rpg/cutscene/cutscene.h new file mode 100644 index 00000000..1230dda0 --- /dev/null +++ b/src/dawn/rpg/cutscene/cutscene.h @@ -0,0 +1,17 @@ +/** + * Copyright (c) 2024 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "dusk.h" + +typedef struct { + +} cutsceneevent_t; + +typedef struct { + +} cutscene_t; \ No newline at end of file diff --git a/src/dawn/rpg/entity/entity.c b/src/dawn/rpg/entity/entity.c index 40f09bc1..c540e702 100644 --- a/src/dawn/rpg/entity/entity.c +++ b/src/dawn/rpg/entity/entity.c @@ -9,6 +9,7 @@ #include "entitydirection.h" #include "rpg/world/map.h" #include "assert/assert.h" +#include "time.h" void entityInit( entity_t *entity, @@ -42,20 +43,36 @@ void entityInit( void entityUpdate(entity_t *entity) { assertNotNull(entity, "Entity cannot be NULL."); - switch(entity->type) { - case ENTITY_TYPE_NULL: - assertUnreachable("Should not be updating a NULL entity."); + switch(entity->state) { + case ENTITY_STATE_IDLE: + switch(entity->type) { + case ENTITY_TYPE_NULL: + assertUnreachable("Should not be updating a NULL entity."); + break; + + case ENTITY_TYPE_PLAYER: + playerUpdate(entity); + break; + + case ENTITY_TYPE_NPC: + break; + + default: + assertUnreachable("Unknown entity type."); + } break; - case ENTITY_TYPE_PLAYER: - playerUpdate(entity); + case ENTITY_STATE_WALKING: + entity->walk.time -= TIME.delta; + if(entity->walk.time > 0.0f) return; + entity->state = ENTITY_STATE_IDLE; break; - case ENTITY_TYPE_NPC: + case ENTITY_STATE_TALKING: break; default: - assertUnreachable("Unknown entity type."); + assertUnreachable("Unknown entity state."); } } @@ -93,6 +110,9 @@ void entityWalk(entity_t *entity, const uint8_t dir) { // Commit to move entity->x = newX; entity->y = newY; + + entity->state = ENTITY_STATE_WALKING; + entity->walk.time = 0.0f; } void entityPositionSet(entity_t *entity, const uint16_t x, const uint16_t y) { diff --git a/src/dawn/rpg/entity/entity.h b/src/dawn/rpg/entity/entity.h index afb7d565..1234fbfd 100644 --- a/src/dawn/rpg/entity/entity.h +++ b/src/dawn/rpg/entity/entity.h @@ -12,8 +12,16 @@ #define ENTITY_TYPE_PLAYER 1 #define ENTITY_TYPE_NPC 2 +#define ENTITY_STATE_IDLE 0 +#define ENTITY_STATE_WALKING 1 +#define ENTITY_STATE_TALKING 2 + typedef struct _map_t map_t; +typedef struct { + float_t time; +} entitywalkstate_t; + typedef struct _entity_t { map_t *map; uint8_t type; @@ -21,7 +29,14 @@ typedef struct _entity_t { uint16_t y; uint8_t layer; uint8_t direction; + uint8_t state; + // State + union { + entitywalkstate_t walk; + }; + + // Type union { player_t player; }; diff --git a/src/dawn/rpg/entity/player.c b/src/dawn/rpg/entity/player.c index 72c0959e..cee7206f 100644 --- a/src/dawn/rpg/entity/player.c +++ b/src/dawn/rpg/entity/player.c @@ -41,6 +41,9 @@ void playerUpdate(entity_t *entity) { target->x, target->y, entity->x, entity->y ); + + target->state = ENTITY_STATE_TALKING; + entity->state = ENTITY_STATE_TALKING; return; } }