Render test
This commit is contained in:
@@ -1,97 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "player.h"
|
||||
|
||||
#define ENTITY_MOVE_SUBPIXEL 4
|
||||
|
||||
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;
|
||||
uint8_t subX, subY;
|
||||
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);
|
||||
void (*update)(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);
|
||||
|
||||
/**
|
||||
* Updates the entity's state based on its type.
|
||||
*
|
||||
* @param entity Pointer to the entity to update.
|
||||
*/
|
||||
void entityUpdate(entity_t *entity);
|
||||
|
||||
/**
|
||||
* Turns the entity to face a specific direction.
|
||||
*
|
||||
* @param entity Pointer to the entity to turn.
|
||||
* @param dir The direction to turn the entity towards.
|
||||
*/
|
||||
void entityTurn(entity_t *entity, const entitydir_t dir);
|
||||
|
||||
/**
|
||||
* Makes the entity walk in the current direction.
|
||||
*
|
||||
* @param entity Pointer to the entity to make walk.
|
||||
*/
|
||||
void entityWalk(entity_t *entity);
|
||||
|
||||
/**
|
||||
* Checks if the entity is currently mid-walking.
|
||||
*
|
||||
* @param entity Pointer to the entity to check.
|
||||
* @return true if the entity is walking, false otherwise.
|
||||
*/
|
||||
bool_t entityIsWalking(const entity_t *entity);
|
||||
|
||||
/**
|
||||
* Resets the entity at a given position.
|
||||
*
|
||||
* @param x The x-coordinate of the entity.
|
||||
* @param y The y-coordinate of the entity.
|
||||
* @return Pointer to the entity at the specified position, or NULL.
|
||||
*/
|
||||
entity_t * entityGetAt(const uint8_t x, const uint8_t y);
|
Reference in New Issue
Block a user