Map loading fixes and improvements

This commit is contained in:
2024-10-22 08:00:48 -05:00
parent ddbef64f43
commit 39d74cc375
17 changed files with 136 additions and 23 deletions

View File

@ -32,7 +32,8 @@ target_sources(${DAWN_TARGET_NAME}
)
# Assets
tool_map(testmap map/testmap.tmx)
tool_map(testmap maps/testmap.tmx)
tool_map(testmap2 maps/testmap2.tmx)
tool_copy(en en.json)
add_dependencies(${DAWN_TARGET_NAME} dawnassets)

View File

@ -93,9 +93,15 @@ void assetMapLoadEntity(
door->type == ASSET_JSON_DATA_TYPE_NUMBER,
"assetMapLoad: Door y is not a number!"
);
entitydirection_t direction = (entitydirection_t)(
assetJsonGetObjectValue(val, "direction")->number
);
door = assetJsonGetObjectValue(val, "direction");
entitydirection_t direction = ENTITY_DIRECTION_SOUTH;
if(door != NULL) {
direction = (entitydirection_t)(
assetJsonGetObjectValue(val, "direction")->number
);
}
door = assetJsonGetObjectValue(val, "map");
maplist_t list;
if(door == NULL) {

View File

@ -10,8 +10,21 @@
#include "game/game.h"
void gameStateMapChangeUpdate() {
// First try and find the player object
entity_t *player = NULL;
entitydirection_t dir = ENTITY_DIRECTION_SOUTH;
if(GAME.currentMap != NULL) {
player = mapEntityGetByType(GAME.currentMap, ENTITY_TYPE_PLAYER);
dir = player->direction;
}
assetMapLoad(MAP_LIST_PATHS[GAME.mapNext], &MAP_MAIN);
GAME.state = GAME_STATE_OVERWORLD;
GAME.currentMap = &MAP_MAIN;
map_t *test = &MAP_MAIN;
// Do not reference player since its invalid, just check if it DID exist
if(GAME.currentMap != NULL && player != NULL) {
player = mapEntityGetByType(GAME.currentMap, ENTITY_TYPE_PLAYER);
player->direction = dir;
}
}

View File

@ -9,7 +9,8 @@
#include "assert/assert.h"
const char_t * MAP_LIST_PATHS[] = {
"testmap.map"
"testmap.map",
"testmap2.map"
};
const int32_t MAP_LIST_COUNT = sizeof(MAP_LIST_PATHS) / sizeof(char_t*);

View File

@ -9,6 +9,7 @@
bool_t tileIsSolid(const tile_t tile) {
switch(tile) {
case TILE_NULL:
case TILE_WATER:
case TILE_BUILDING_WALL:
case TILE_ROOF: