source: trunk/src/layer.cpp @ 91

Last change on this file since 91 was 79, checked in by sam, 11 years ago

Rendering starts to work again. There is no Z-sorting yet.

  • Property svn:keywords set to Id
File size: 802 bytes
RevLine 
[38]1
[75]2#include <stdlib.h>
3
[38]4#include "layer.h"
5
[79]6Layer::Layer(int w, int h, int z, uint32_t *in_data)
[38]7{
8    width = w;
9    height = h;
[79]10    altitude = z;
[74]11    data = in_data;
[38]12
[70]13#if 0
[38]14    fread(data, sizeof(unsigned int), width * height, fp);
15    for (int n = 0; n < width * height; n++)
16    {
17        unsigned int i = data[n];
18        // XXX: endianness swapping might be necessary here
19        data[n] = i ? i - 1 : 0;
20    }
[70]21#endif
[38]22}
23
24Layer::~Layer()
25{
[75]26    free(data);
[38]27}
28
[79]29void Layer::Render(Scene *scene, int x, int y, int z)
[75]30{
[79]31    for (int j = 0; j < height; j++)
32        for (int i = 0; i < width; i++)
33            if (data[j * width + i])
34                scene->AddTile(data[j * width + i],
35                               i * 32 - x, j * 32 - y, altitude + z);
[75]36}
37
[47]38int Layer::GetZ()
39{
[79]40    return altitude;
[47]41}
42
Note: See TracBrowser for help on using the repository browser.