Example rendering

This commit is contained in:
2025-10-08 22:34:27 -05:00
parent 20cf016b06
commit fef31b9102
9 changed files with 133 additions and 10 deletions

View File

@@ -6,9 +6,21 @@
*/
#include "scenemap.h"
#include "scene/scenedata.h"
#include "display/spritebatch.h"
#include "assert/assert.h"
#include "rpg/entity/entity.h"
#define TILE_WIDTH 1
#define TILE_HEIGHT TILE_WIDTH
errorret_t sceneMapInit(scenedata_t *data) {
cameraInitPerspective(&data->sceneMap.camera);
data->sceneMap.camera.lookat.position[0] = 3;
data->sceneMap.camera.lookat.position[1] = 3;
data->sceneMap.camera.lookat.position[2] = 3;
errorOk();
}
@@ -16,21 +28,29 @@ void sceneMapUpdate(scenedata_t *data) {
}
void sceneMapRender(scenedata_t *data) {
cameraPushMatrix(&data->sceneMap.camera);
entity_t *ent = ENTITIES;
do {
sceneMapRenderEntity(ent);
} while(++ent, ent < &ENTITIES[ENTITY_COUNT]);
spriteBatchFlush();
cameraPopMatrix();
}
void sceneMapRenderEntity(const entity_t *entity) {
assertNotNull(entity);
assertNotNull(entity, "Entity cannot be NULL");
if(entity->type == ENTITY_TYPE_NULL) return;
float_t x = worldChunkPosToF32(entity->position[0], TILE_WIDTH);
float_t y = worldChunkPosToF32(entity->position[1], TILE_HEIGHT);
spriteBatchPush(
NULL,
0.0f, 0.0f,
32.0f, 32.0f,
x, y,
x + TILE_WIDTH, y + TILE_HEIGHT,
COLOR_RED,
0.0f, 0.0f,
1.0f, 1.0f

View File

@@ -8,9 +8,11 @@
#pragma once
#include "scene/scene.h"
#include "rpg/entity/entity.h"
#include "display/camera.h"
typedef struct {
int32_t nothing;
camera_t camera;
} scenemap_t;
errorret_t sceneMapInit(scenedata_t *data);