Overworld render test.

This commit is contained in:
2025-09-11 23:33:24 -05:00
parent b4d94c2cbe
commit 964a9f64f2
32 changed files with 249 additions and 1219 deletions

View File

@@ -6,94 +6,51 @@
*/
#pragma once
#include "direction.h"
// #include "direction.h"
#include "rpg/entity/player.h"
#include "npc.h"
// #include "npc.h"
#define ENTITY_COUNT_MAX 32
#define ENTITY_TURN_DURATION 0.075f // Duration for turning in seconds
#define ENTITY_MOVE_DURATION 0.1f // Duration for moving 1 tile, in seconds.
#define ENTITY_PLAYER_INDEX 0
// #define ENTITY_TURN_DURATION 0.075f // Duration for turning in seconds
// #define ENTITY_MOVE_DURATION 0.1f // Duration for moving 1 tile, in seconds.
// #define ENTITY_PLAYER_INDEX 0
typedef struct {
void (*init)(entity_t *entity);
void (*update)(entity_t *entity);
} entitycallback_t;
typedef enum {
ENTITY_TYPE_NULL = 0,
ENTITY_TYPE_PLAYER = 1,
ENTITY_TYPE_NPC = 2,
ENTITY_TYPE_NULL,
ENTITY_TYPE_PLAYER,
ENTITY_TYPE_NPC,
ENTITY_TYPE_COUNT
} entitytype_t;
#define ENTITY_TYPE_COUNT 3
typedef struct _entity_t {
uint32_t id;// Completely unique ID for this entity.
int32_t x, y;
int8_t subX, subY;
uint8_t moveSpeed;
typedef struct entity_s {
// uint32_t id;// Completely unique ID for this entity.
float_t x, y;
entitytype_t type;
direction_t dir;
// direction_t dir;
union {
npc_t npc;
playerentity_t player;
player_t player;
};
} entity_t;
// typedef struct {
// void (*load) (entity_t *entity, const entity_t *source);
// void (*update) (entity_t *entity);
// void (*interact)(entity_t *player, entity_t *self);
// } entitycallback_t;
extern entity_t ENTITIES[ENTITY_COUNT_MAX];
// extern entitycallback_t ENTITY_CALLBACKS[ENTITY_TYPE_COUNT];
extern entitycallback_t ENTITY_CALLBACKS[ENTITY_TYPE_COUNT];
/**
* Loads an entity from the generated entity data.
* Initializes an entity structure.
*
* @param entity Pointer to the entity to initialize.
* @param source Pointer to the source entity data.
* @param entity Pointer to the entity structure to initialize.
* @param type The type of the entity.
*/
void entityInit(entity_t *entity);
void entityInit(entity_t *entity, const entitytype_t type);
/**
* Updates the entity's state.
* Updates an entity.
*
* @param entity Pointer to the entity to update.
* @param entity Pointer to the entity structure to update.
*/
void entityUpdate(entity_t *entity);
/**
* Moves the entity by the specified x and y offsets.
*
* @param entity Pointer to the entity to move.
* @param moveSpeed The speed at which to move the entity.
*/
void entityMove(entity_t *entity, const uint8_t moveSpeed);
/**
* Turns the entity to face the specified direction.
*
* @param entity Pointer to the entity to turn.
* @param dir The direction to turn the entity to.
*/
void entityTurn(entity_t *entity, const direction_t dir);
/**
* Returns whether or not an entity is currently moving.
*
* @param entity Pointer to the entity to check.
* @return True if the entity is moving, false otherwise.
*/
bool_t entityIsMoving(const entity_t *entity);
/**
* Gets the entity at the specified tile coordinates.
*
* @param tileX The x coordinate of the tile to get the entity from.
* @param tileY The y coordinate of the tile to get the entity from.
* @return Pointer to the entity at the specified coordinates, or NULL if no
* entity exists there.
*/
entity_t *entityGetAt(
const int32_t tileX,
const int32_t tileY
);
void entityUpdate(entity_t *entity);