Files
dusk/src/rpg/entity/entity.h
2025-10-08 07:11:53 -05:00

55 lines
1.0 KiB
C

/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "direction.h"
#include "rpg/entity/player.h"
#include "npc.h"
#include "physics/physics.h"
#define ENTITY_FRICTION 0.9f
#define ENTITY_MIN_VELOCITY 0.05f
typedef struct map_s map_t;
typedef enum {
ENTITY_TYPE_NULL,
ENTITY_TYPE_PLAYER,
ENTITY_TYPE_NPC,
ENTITY_TYPE_COUNT
} entitytype_t;
typedef struct entity_s {
map_t *map;
entitytype_t type;
direction_t direction;
vec2 position;
vec2 velocity;
union {
player_t player;
npc_t npc;
};
} entity_t;
/**
* Initializes an entity structure.
*
* @param entity Pointer to the entity structure to initialize.
* @param type The type of the entity.
* @param map Pointer to the map the entity belongs to.
*/
void entityInit(entity_t *entity, const entitytype_t type, map_t *map);
/**
* Updates an entity.
*
* @param entity Pointer to the entity structure to update.
*/
void entityUpdate(entity_t *entity);