Read in tile data from tilemap
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
#include "assert/assert.h"
|
||||
#include "util/memory.h"
|
||||
#include "world/world.h"
|
||||
#include "world/tiledata.h"
|
||||
#include "physics/physics.h"
|
||||
|
||||
entity_t ENTITIES[ENTITY_COUNT_MAX] = {0};
|
||||
@ -89,14 +90,10 @@ void entityUpdate(entity_t *entity) {
|
||||
uint8_t chunkTileX = tileX % CHUNK_WIDTH;
|
||||
uint8_t chunkTileY = tileY % CHUNK_HEIGHT;
|
||||
tile_t tile = chunk->tilesBase[chunkTileY * CHUNK_WIDTH + chunkTileX];
|
||||
|
||||
tilesolidtype_t solidType = (
|
||||
tile < TILE_META_DATA_COUNT ? TILE_META_DATA[tile].solidType :
|
||||
TILE_SOLID_NONE
|
||||
);
|
||||
|
||||
// Determine tile collision type
|
||||
collisionresult_t collision;
|
||||
switch(solidType) {
|
||||
switch(TILE_META_DATA[tile].solidType) {
|
||||
case TILE_SOLID_FULL:
|
||||
collision = physicsCheckCircleAABB(
|
||||
newX, newY, selfCircR,
|
||||
@ -105,6 +102,7 @@ void entityUpdate(entity_t *entity) {
|
||||
FIXED248(TILE_WIDTH_HEIGHT, 0),
|
||||
FIXED248(TILE_WIDTH_HEIGHT, 0)
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
continue;
|
||||
|
@ -8,5 +8,4 @@ target_sources(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
chunk.c
|
||||
overworld.c
|
||||
tile.c
|
||||
)
|
@ -1,8 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "tile.h"
|
@ -23,30 +23,4 @@ typedef enum {
|
||||
|
||||
typedef struct {
|
||||
tilesolidtype_t solidType;
|
||||
} tilemeta_t;
|
||||
|
||||
static const tilemeta_t TILE_META_DATA[] = {
|
||||
{TILE_SOLID_NONE}, // 0
|
||||
{TILE_SOLID_NONE}, // 1
|
||||
{TILE_SOLID_NONE}, // 2
|
||||
{TILE_SOLID_NONE}, // 3
|
||||
{TILE_SOLID_NONE}, // 4
|
||||
{TILE_SOLID_NONE}, // 5
|
||||
{TILE_SOLID_NONE}, // 6
|
||||
{TILE_SOLID_NONE}, // 7
|
||||
{TILE_SOLID_NONE}, // 8
|
||||
{TILE_SOLID_NONE}, // 9
|
||||
{TILE_SOLID_NONE}, // 10
|
||||
{TILE_SOLID_NONE}, // 11
|
||||
{TILE_SOLID_NONE}, // 12
|
||||
{TILE_SOLID_NONE}, // 13
|
||||
{TILE_SOLID_NONE}, // 14
|
||||
{TILE_SOLID_NONE}, // 15
|
||||
{TILE_SOLID_NONE}, // 16
|
||||
{TILE_SOLID_NONE}, // 17
|
||||
{TILE_SOLID_FULL}, // 18
|
||||
{TILE_SOLID_FULL}, // 19
|
||||
{TILE_SOLID_FULL}, // 19
|
||||
};
|
||||
|
||||
#define TILE_META_DATA_COUNT (sizeof(TILE_META_DATA) / sizeof(tilemeta_t))
|
||||
} tilemetadata_t;
|
Reference in New Issue
Block a user