Tile Z is now hypotenused to 1 rather than stretching to have Z of 1.

This commit is contained in:
2026-07-01 16:27:59 -05:00
parent 874c6258ab
commit 172dc5d37b
15 changed files with 334 additions and 23 deletions
+3 -2
View File
@@ -11,6 +11,7 @@
void entityAnimIdleUpdate(entity_t *entity) {
entity->renderPosition[0] = (float_t)entity->position.x;
entity->renderPosition[1] = (float_t)entity->position.y;
entity->renderPosition[2] = (float_t)entity->position.z
+ entityAnimTileZOffset(entity->position);
entity->renderPosition[2] = (
(float_t)entity->position.z + entityAnimTileZOffset(entity->position)
) * WORLD_LAYER_HEIGHT;
}
+1 -1
View File
@@ -20,5 +20,5 @@ void entityAnimRunUpdate(entity_t *entity) {
entity->renderPosition[1] = (float_t)entity->lastPosition.y + t * (
(float_t)entity->position.y - (float_t)entity->lastPosition.y
);
entity->renderPosition[2] = zFrom + t * (zTo - zFrom);
entity->renderPosition[2] = (zFrom + t * (zTo - zFrom)) * WORLD_LAYER_HEIGHT;
}
+3 -2
View File
@@ -11,6 +11,7 @@
void entityAnimTurnUpdate(entity_t *entity) {
entity->renderPosition[0] = (float_t)entity->position.x;
entity->renderPosition[1] = (float_t)entity->position.y;
entity->renderPosition[2] = (float_t)entity->position.z
+ entityAnimTileZOffset(entity->position);
entity->renderPosition[2] = (
(float_t)entity->position.z + entityAnimTileZOffset(entity->position)
) * WORLD_LAYER_HEIGHT;
}
+1 -1
View File
@@ -20,5 +20,5 @@ void entityAnimWalkUpdate(entity_t *entity) {
entity->renderPosition[1] = (float_t)entity->lastPosition.y + t * (
(float_t)entity->position.y - (float_t)entity->lastPosition.y
);
entity->renderPosition[2] = zFrom + t * (zTo - zFrom);
entity->renderPosition[2] = (zFrom + t * (zTo - zFrom)) * WORLD_LAYER_HEIGHT;
}
+9 -2
View File
@@ -296,7 +296,9 @@ void mapChunkLoaded(void *params, void *user) {
);
worldpos_t wp;
chunkPosToWorldPos(&chunk->position, &wp);
vec3 wpf = { (float_t)wp.x, (float_t)wp.y, (float_t)wp.z };
vec3 wpf = {
(float_t)wp.x, (float_t)wp.y, (float_t)wp.z * WORLD_LAYER_HEIGHT
};
for(uint8_t m = 0; m < meshCount; m++) {
stringCopy(
chunk->modelNames[m],
@@ -307,8 +309,13 @@ void mapChunkLoaded(void *params, void *user) {
entry->data.chunk.meshOffsets[m],
chunk->meshOffsets[m]
);
vec3 scaledOffset = {
chunk->meshOffsets[m][0],
chunk->meshOffsets[m][1],
chunk->meshOffsets[m][2] * WORLD_LAYER_HEIGHT
};
vec3 pos;
glm_vec3_add(wpf, chunk->meshOffsets[m], pos);
glm_vec3_add(wpf, scaledOffset, pos);
glm_translate_make(chunk->meshModels[m], pos);
chunk->modelEntries[m] = entry->data.chunk.modelEntries[m];
entry->data.chunk.modelEntries[m] = NULL;
+6
View File
@@ -11,6 +11,12 @@
#define TILE_SIZE_PIXELS 24
// World-space Z distance of one Z-layer/story, in render/world-float
// space. A ramp rises this much over a horizontal run of 1 tile-width;
// chosen as 1/sqrt(2) so the ramp's slope, derived from a 45-45-90
// triangle with hypotenuse 1, matches the length of a flat tile edge.
#define WORLD_LAYER_HEIGHT 0.70710678f
#define CHUNK_WIDTH 16
#define CHUNK_HEIGHT 16
#define CHUNK_DEPTH 4
+1 -1
View File
@@ -65,7 +65,7 @@ errorret_t rpgCameraUpdate(void) {
chunkpos_t chunkPos = {
.x = (chunkunit_t)floorf(pos[0] / CHUNK_WIDTH),
.y = (chunkunit_t)floorf(pos[1] / CHUNK_HEIGHT),
.z = (chunkunit_t)floorf(pos[2] / CHUNK_DEPTH)
.z = (chunkunit_t)floorf(pos[2] / WORLD_LAYER_HEIGHT / CHUNK_DEPTH)
};
errorChain(mapPositionSet((chunkpos_t){
+1 -1
View File
@@ -92,7 +92,7 @@ errorret_t sceneOverworldRender(scenedata_t *sceneData) {
spritebatchsprite_t sprite;
glm_vec3_copy(ent->renderPosition, sprite.min);
glm_vec3_add(sprite.min, (vec3){ 0, 0, 0.05f }, sprite.min);// Stop Fight
glm_vec3_add(sprite.min, (vec3){ 0, -0.05f, 0.05f }, sprite.min);// Stop Fight
glm_vec3_copy(sprite.min, sprite.max);
glm_vec3_add(sprite.max, (vec3){ 1, 1, 0 }, sprite.max);
glm_vec2_copy((vec2){ 0, 0 }, sprite.uvMin);