Files
dusk/src/rpg/rpg.c
2025-11-03 19:50:23 -06:00

58 lines
1.2 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/world/world.h"
#include "time/time.h"
#include "rpgcamera.h"
#include "util/memory.h"
errorret_t rpgInit(void) {
memoryZero(ENTITIES, sizeof(ENTITIES));
// Init the world.
worldInit();
// Initialize the camera
rpgCameraInit();
// TEST: Create some entities.
entity_t *ent;
ent = &ENTITIES[0];
entityInit(ent, ENTITY_TYPE_PLAYER);
RPG_CAMERA.mode = RPG_CAMERA_MODE_FOLLOW_ENTITY;
RPG_CAMERA.followEntity.followEntityId = ent->id;
ent->position.x = 4, ent->position.y = 4;
ent = &ENTITIES[1];
entityInit(ent, ENTITY_TYPE_NPC);
ent->position.x = 6, ent->position.y = 6;
// All Good!
errorOk();
}
void rpgUpdate(void) {
if(!TIME.fixedUpdate) return;
// TODO: Do not update if the scene is not the map scene?
// Update the world.
worldUpdate();
// Update overworld ents.
entity_t *ent = &ENTITIES[0];
do {
if(ent->type == ENTITY_TYPE_NULL) continue;
entityUpdate(ent);
} while(++ent < &ENTITIES[ENTITY_COUNT]);
}
void rpgDispose(void) {
}