57 lines
1.1 KiB
C
57 lines
1.1 KiB
C
/**
|
|
* Copyright (c) 2025 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include "rpg/entity/entity.h"
|
|
|
|
#define MAP_ENTITY_COUNT_MAX 32
|
|
|
|
#define MAP_WIDTH_MAX 64
|
|
#define MAP_HEIGHT_MAX 64
|
|
#define MAP_TILE_COUNT_MAX (MAP_WIDTH_MAX * MAP_HEIGHT_MAX)
|
|
#define MAP_LAYER_COUNT_MAX 2
|
|
|
|
typedef struct {
|
|
uint8_t id;
|
|
} tile_t;
|
|
|
|
typedef struct {
|
|
tile_t tiles[MAP_TILE_COUNT_MAX];
|
|
} maplayer_t;
|
|
|
|
typedef struct map_s {
|
|
entity_t entities[MAP_ENTITY_COUNT_MAX];
|
|
uint8_t entityCount;
|
|
|
|
uint8_t width, height;
|
|
maplayer_t base;
|
|
maplayer_t overlay;
|
|
} map_t;
|
|
|
|
extern map_t testMap;
|
|
|
|
/**
|
|
* Initializes a map structure.
|
|
*
|
|
* @param map Pointer to the map structure to initialize.
|
|
*/
|
|
void mapInit(map_t *map);
|
|
|
|
/**
|
|
* Updates the map and its entities.
|
|
*
|
|
* @param map Pointer to the map structure to update.
|
|
*/
|
|
void mapUpdate(map_t *map);
|
|
|
|
/**
|
|
* Adds (but does not initialize) an entity on the map.
|
|
*
|
|
* @param map Pointer to the map structure.
|
|
* @return Pointer to the added entity.
|
|
*/
|
|
entity_t * mapEntityAdd(map_t *map); |