This commit is contained in:
2025-10-09 15:07:07 -05:00
parent 7622f81309
commit c4c43b23ad
11 changed files with 162 additions and 32 deletions

View File

@@ -11,9 +11,9 @@
#include "assert/assert.h"
#include "rpg/entity/entity.h"
#include "display/screen.h"
#include "rpg/rpgcamera.h"
#define TILE_WIDTH 8
#define TILE_HEIGHT TILE_WIDTH
#define TILE_SIZE 8
errorret_t sceneMapInit(scenedata_t *data) {
cameraInitPerspective(&data->sceneMap.camera);
@@ -31,6 +31,12 @@ void sceneMapRender(scenedata_t *data) {
data->sceneMap.camera.perspective.fov / 2.0f
) * ((float_t)SCREEN.height / 2.0f);
for(uint8_t i = 0; i < WORLD_DIMENSIONS; i++) {
data->sceneMap.camera.lookat.target[i] = worldPosToF32(
RPG_CAMERA.position[i], TILE_SIZE
);
}
glm_vec3_copy((vec3){
data->sceneMap.camera.lookat.target[0],
data->sceneMap.camera.lookat.target[1] + camOffset,
@@ -55,15 +61,15 @@ void sceneMapRenderEntity(const entity_t *entity) {
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);
x -= TILE_WIDTH * 0.5f;
y -= TILE_HEIGHT * 0.5f;
float_t x = worldPosToF32(entity->position[0], TILE_SIZE);
float_t y = worldPosToF32(entity->position[1], TILE_SIZE);
x -= TILE_SIZE * 0.5f;
y -= TILE_SIZE * 0.5f;
spriteBatchPush(
NULL,
x, y,
x + TILE_WIDTH, y + TILE_HEIGHT,
x + TILE_SIZE, y + TILE_SIZE,
COLOR_RED,
0.0f, 0.0f,
1.0f, 1.0f