Przeglądaj źródła

Fix z-sorting of tiles. For now.

legacy
Sam Hocevar sam 14 lat temu
rodzic
commit
8d4e2c9c4c
6 zmienionych plików z 15 dodań i 13 usunięć
  1. +2
    -2
      src/debugsprite.cpp
  2. +4
    -3
      src/layer.cpp
  3. +2
    -2
      src/layer.h
  4. +3
    -2
      src/map.cpp
  5. +3
    -3
      src/scene.cpp
  6. +1
    -1
      src/scene.h

+ 2
- 2
src/debugsprite.cpp Wyświetl plik

@@ -52,8 +52,8 @@ void DebugSprite::TickRender(float delta_time)
{
Asset::TickRender(delta_time);

data->game->GetScene()->AddTile((data->tiler << 16) | 15, 300, 200, 200);
data->game->GetScene()->AddTile((data->tiler << 16) | 31, 300, 232, 200);
data->game->GetScene()->AddTile((data->tiler << 16) | 15, 300, 200, 32, 1);
data->game->GetScene()->AddTile((data->tiler << 16) | 31, 300, 232, 0, 1);
}

DebugSprite::~DebugSprite()


+ 4
- 3
src/layer.cpp Wyświetl plik

@@ -11,11 +11,12 @@

#include "layer.h"

Layer::Layer(int w, int h, int z, uint32_t *in_data)
Layer::Layer(int w, int h, int z, int o, uint32_t *in_data)
{
width = w;
height = h;
altitude = z;
orientation = o;
data = in_data;

#if 0
@@ -39,8 +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],
i * 32 - x, j * 32 - y, altitude + z);
scene->AddTile(data[j * width + i], i * 32 - x, j * 32 - y,
altitude + z, orientation);
}

int Layer::GetZ()


+ 2
- 2
src/layer.h Wyświetl plik

@@ -19,7 +19,7 @@
class Layer
{
public:
Layer(int w, int h, int z, uint32_t *data);
Layer(int w, int h, int z, int o, uint32_t *data);
~Layer();

int GetZ();
@@ -27,7 +27,7 @@ public:
void Render(Scene *scene, int x, int y, int z);

private:
int width, height, altitude;
int width, height, altitude, orientation;
uint32_t *data;
};



+ 3
- 2
src/map.cpp Wyświetl plik

@@ -103,8 +103,9 @@ Map::Map(char const *path)

if (ntiles == data->width * data->height)
{
data->layers[data->nlayers] = new Layer(data->width,
data->height, level, tiles);
Layer *l = new Layer(data->width, data->height,
level, orientation, tiles);
data->layers[data->nlayers] = l;
data->nlayers++;
tiles = NULL;
//fprintf(stderr, "new layer %ix%i\n", data->width, data->height);


+ 3
- 3
src/scene.cpp Wyświetl plik

@@ -32,7 +32,7 @@ private:
Tile const *t1 = (Tile const *)p1;
Tile const *t2 = (Tile const *)p2;

return t1->prio - t2->prio;
return t2->prio - t1->prio;
}

Tile *tiles;
@@ -55,12 +55,12 @@ Scene::~Scene()
delete data;
}

void Scene::AddTile(uint32_t code, int x, int y, int z)
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 = 0;
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;


+ 1
- 1
src/scene.h Wyświetl plik

@@ -21,7 +21,7 @@ public:
Scene();
~Scene();

void AddTile(uint32_t code, int x, int y, int z);
void AddTile(uint32_t code, int x, int y, int z, int o);
void Render();

private:


Ładowanie…
Anuluj
Zapisz