This commit is contained in:
2025-06-08 14:38:22 -05:00
parent 8411c2981b
commit 0b6b33721b
69 changed files with 210 additions and 3384 deletions

54
src/rpg/entity/entity.h Normal file
View File

@@ -0,0 +1,54 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "player.h"
typedef enum {
ENTITY_DIR_UP = 0,
ENTITY_DIR_DOWN = 1,
ENTITY_DIR_LEFT = 2,
ENTITY_DIR_RIGHT = 3,
ENTITY_DIR_NORTH = ENTITY_DIR_UP,
ENTITY_DIR_SOUTH = ENTITY_DIR_DOWN,
ENTITY_DIR_WEST = ENTITY_DIR_LEFT,
ENTITY_DIR_EAST = ENTITY_DIR_RIGHT
} entitydir_t;
typedef enum {
ENTITY_TYPE_NULL = 0,
ENTITY_TYPE_PLAYER = 1,
} entitytype_t;
#define ENTITY_TYPE_COUNT (ENTITY_TYPE_PLAYER + 1)
typedef struct _entity_t {
entitytype_t type;
uint8_t x, y;
entitydir_t dir;
// Per type data
union {
player_t player;
};
} entity_t;
#define ENTITY_COUNT 16
extern entity_t ENTITIES[ENTITY_COUNT];
typedef struct {
void (*init)(entity_t *entity);
} entitycallbacks_t;
extern entitycallbacks_t ENTITY_CALLBACKS[ENTITY_TYPE_COUNT];
/**
* Initializes an entity with the given type.
*
* @param entity Pointer to the entity to initialize.
* @param type The type of the entity to initialize.
*/
void entityInit(entity_t *entity, const entitytype_t type);