From 8d659bb02e3606735cd9179db851a4e51e380d84 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 19 Aug 2010 00:58:31 +0000 Subject: [PATCH] Fix Z-sorting yet again, and add real level support to map loading. --- src/debugsprite.cpp | 4 ++-- src/layer.cpp | 5 +++-- src/map.cpp | 1 + src/scene.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/debugsprite.cpp b/src/debugsprite.cpp index 177fdf44..363dbd8b 100644 --- a/src/debugsprite.cpp +++ b/src/debugsprite.cpp @@ -52,8 +52,8 @@ void DebugSprite::TickRender(float delta_time) { Asset::TickRender(delta_time); - data->game->GetScene()->AddTile((data->tiler << 16) | 15, 300, 200, 32, 1); - data->game->GetScene()->AddTile((data->tiler << 16) | 31, 300, 200, 0, 1); + data->game->GetScene()->AddTile((data->tiler << 16) | 15, 320, 240, 32, 1); + data->game->GetScene()->AddTile((data->tiler << 16) | 31, 320, 240, 0, 1); } DebugSprite::~DebugSprite() diff --git a/src/layer.cpp b/src/layer.cpp index 132a7703..399f265b 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -7,7 +7,7 @@ # include "config.h" #endif -#include +#include #include "layer.h" @@ -40,7 +40,8 @@ void Layer::Render(Scene *scene, int x, int y, int z) for (int j = 0; j < height; j++) for (int i = 0; i < width; i++) if (data[j * width + i]) - scene->AddTile(data[j * width + i], x + i * 32, y + j * 32, + scene->AddTile(data[j * width + i], + x + i * 32, y + j * 32 + altitude, altitude + z, orientation); } diff --git a/src/map.cpp b/src/map.cpp index bf7e2320..a630ade7 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -130,6 +130,7 @@ Map::Map(char const *path) data->layers = (Layer **)realloc(data->layers, sizeof(Layer **) * (data->nlayers + 1)); orientation = toupper(a) == 'V' ? 1 : 0; + level = i * 32; data->width = j; data->height = k; tiles = (uint32_t *)malloc(j * k * sizeof(uint32_t)); diff --git a/src/scene.cpp b/src/scene.cpp index c25783a3..405b1f39 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -72,7 +72,7 @@ void Scene::AddTile(uint32_t code, int x, int y, int z, int o) if ((data->ntiles % 1024) == 0) data->tiles = (Tile *)realloc(data->tiles, (data->ntiles + 1024) * sizeof(Tile)); - data->tiles[data->ntiles].prio = y - 2 * 32 * z + (o ? 0 : 32); + data->tiles[data->ntiles].prio = -y - 2 * 32 * z + (o ? 0 : 32); data->tiles[data->ntiles].code = code; data->tiles[data->ntiles].x = x; data->tiles[data->ntiles].y = y;