@@ -52,8 +52,8 @@ void DebugSprite::TickRender(float delta_time) | |||||
{ | { | ||||
Asset::TickRender(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() | DebugSprite::~DebugSprite() | ||||
@@ -11,11 +11,12 @@ | |||||
#include "layer.h" | #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; | width = w; | ||||
height = h; | height = h; | ||||
altitude = z; | altitude = z; | ||||
orientation = o; | |||||
data = in_data; | data = in_data; | ||||
#if 0 | #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 j = 0; j < height; j++) | ||||
for (int i = 0; i < width; i++) | for (int i = 0; i < width; i++) | ||||
if (data[j * 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() | int Layer::GetZ() | ||||
@@ -19,7 +19,7 @@ | |||||
class Layer | class Layer | ||||
{ | { | ||||
public: | public: | ||||
Layer(int w, int h, int z, uint32_t *data); | |||||
Layer(int w, int h, int z, int o, uint32_t *data); | |||||
~Layer(); | ~Layer(); | ||||
int GetZ(); | int GetZ(); | ||||
@@ -27,7 +27,7 @@ public: | |||||
void Render(Scene *scene, int x, int y, int z); | void Render(Scene *scene, int x, int y, int z); | ||||
private: | private: | ||||
int width, height, altitude; | |||||
int width, height, altitude, orientation; | |||||
uint32_t *data; | uint32_t *data; | ||||
}; | }; | ||||
@@ -103,8 +103,9 @@ Map::Map(char const *path) | |||||
if (ntiles == data->width * data->height) | 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++; | data->nlayers++; | ||||
tiles = NULL; | tiles = NULL; | ||||
//fprintf(stderr, "new layer %ix%i\n", data->width, data->height); | //fprintf(stderr, "new layer %ix%i\n", data->width, data->height); | ||||
@@ -32,7 +32,7 @@ private: | |||||
Tile const *t1 = (Tile const *)p1; | Tile const *t1 = (Tile const *)p1; | ||||
Tile const *t2 = (Tile const *)p2; | Tile const *t2 = (Tile const *)p2; | ||||
return t1->prio - t2->prio; | |||||
return t2->prio - t1->prio; | |||||
} | } | ||||
Tile *tiles; | Tile *tiles; | ||||
@@ -55,12 +55,12 @@ Scene::~Scene() | |||||
delete data; | 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) | if ((data->ntiles % 1024) == 0) | ||||
data->tiles = (Tile *)realloc(data->tiles, | data->tiles = (Tile *)realloc(data->tiles, | ||||
(data->ntiles + 1024) * sizeof(Tile)); | (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].code = code; | ||||
data->tiles[data->ntiles].x = x; | data->tiles[data->ntiles].x = x; | ||||
data->tiles[data->ntiles].y = y; | data->tiles[data->ntiles].y = y; | ||||
@@ -21,7 +21,7 @@ public: | |||||
Scene(); | Scene(); | ||||
~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(); | void Render(); | ||||
private: | private: | ||||