Example rendering
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user