66 lines
1.4 KiB
C
66 lines
1.4 KiB
C
/**
|
|
* Copyright (c) 2025 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "rpg.h"
|
|
#include "entity/entity.h"
|
|
#include "rpg/overworld/map.h"
|
|
#include "rpg/cutscene/cutscenesystem.h"
|
|
#include "time/time.h"
|
|
#include "rpgcamera.h"
|
|
#include "rpgtextbox.h"
|
|
#include "util/memory.h"
|
|
#include "assert/assert.h"
|
|
|
|
errorret_t rpgInit(void) {
|
|
memoryZero(ENTITIES, sizeof(ENTITIES));
|
|
|
|
// Init cutscene subsystem
|
|
cutsceneSystemInit();
|
|
|
|
errorChain(mapInit());
|
|
|
|
rpgCameraInit();
|
|
rpgTextboxInit();
|
|
|
|
// TEST: Create some entities.
|
|
// uint8_t entIndex = entityGetAvailable();
|
|
// assertTrue(entIndex != 0xFF, "No available entity slots!.");
|
|
// entity_t *ent = &ENTITIES[entIndex];
|
|
// entityInit(ent, ENTITY_TYPE_PLAYER);
|
|
// RPG_CAMERA.mode = RPG_CAMERA_MODE_FOLLOW_ENTITY;
|
|
// RPG_CAMERA.followEntity.followEntityId = ent->id;
|
|
// ent->position.x = 2, ent->position.y = 2;
|
|
|
|
// All Good!
|
|
errorOk();
|
|
}
|
|
|
|
errorret_t rpgUpdate(void) {
|
|
#if TIME_FIXED == 0
|
|
if(TIME.dynamicUpdate) {
|
|
errorOk();
|
|
}
|
|
#endif
|
|
|
|
// TODO: Do not update if the scene is not the map scene?
|
|
mapUpdate();
|
|
|
|
// Update overworld ents.
|
|
entity_t *ent = &ENTITIES[0];
|
|
do {
|
|
if(ent->type == ENTITY_TYPE_NULL) continue;
|
|
entityUpdate(ent);
|
|
} while(++ent < &ENTITIES[ENTITY_COUNT]);
|
|
|
|
cutsceneSystemUpdate();
|
|
errorChain(rpgCameraUpdate());
|
|
errorOk();
|
|
}
|
|
|
|
void rpgDispose(void) {
|
|
mapDispose();
|
|
} |