load map first pass

This commit is contained in:
2025-09-19 12:43:57 -05:00
parent 2f40724258
commit 061352bcff
14 changed files with 256 additions and 52 deletions

View File

@@ -6,28 +6,44 @@
*/
#include "rpg.h"
#include "rpg/world/map.h"
#include "util/memory.h"
#include "asset/assetmanager.h"
map_t testMap;
rpg_t RPG;
asset_t *asset;
ref_t assetRef;
void rpgInit() {
mapInit(&testMap);
testMap.width = 2;
testMap.height = 2;
for(uint32_t i = 0; i < testMap.width * testMap.height; i++) {
testMap.base.tiles[i].id = 1;
memoryZero(&RPG, sizeof(RPG));
errorret_t ret = assetManagerLoadAsset("map/untitled.drm", &asset, &assetRef);
if(ret.code != ERROR_OK) {
errorPrint(ret);
errorCatch(ret);
return;
}
RPG.map = &asset->rpgMap.map;
entity_t *ent = mapEntityAdd(&testMap);
entityInit(ent, ENTITY_TYPE_PLAYER, &testMap);
// mapInit(&testMap);
// testMap.width = 2;
// testMap.height = 2;
// for(uint32_t i = 0; i < testMap.width * testMap.height; i++) {
// testMap.base.tiles[i].id = 1;
// }
entity_t *npc = mapEntityAdd(&testMap);
entityInit(npc, ENTITY_TYPE_NPC, &testMap);
npc->position[0] = 32.0f;
npc->position[1] = 32.0f;
// entity_t *ent = mapEntityAdd(&testMap);
// entityInit(ent, ENTITY_TYPE_PLAYER, &testMap);
// entity_t *npc = mapEntityAdd(&testMap);
// entityInit(npc, ENTITY_TYPE_NPC, &testMap);
// npc->position[0] = 32.0f;
// npc->position[1] = 32.0f;
}
void rpgUpdate() {
mapUpdate(&testMap);
if(RPG.map != NULL) {
mapUpdate(RPG.map);
}
}