Browse Source

Fix Z-sorting yet again, and add real level support to map loading.

legacy
Sam Hocevar sam 14 years ago
parent
commit
8d659bb02e
4 changed files with 7 additions and 5 deletions
  1. +2
    -2
      src/debugsprite.cpp
  2. +3
    -2
      src/layer.cpp
  3. +1
    -0
      src/map.cpp
  4. +1
    -1
      src/scene.cpp

+ 2
- 2
src/debugsprite.cpp View File

@@ -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()


+ 3
- 2
src/layer.cpp View File

@@ -7,7 +7,7 @@
# include "config.h"
#endif

#include <stdlib.h>
#include <cstdlib>

#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);
}



+ 1
- 0
src/map.cpp View File

@@ -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));


+ 1
- 1
src/scene.cpp View File

@@ -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;


Loading…
Cancel
Save