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
Line 
1
2#include <stdlib.h>
3
4#include "layer.h"
5
6Layer::Layer(int w, int h, int z, uint32_t *in_data)
7{
8    width = w;
9    height = h;
10    altitude = z;
11    data = in_data;
12
13#if 0
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    }
21#endif
22}
23
24Layer::~Layer()
25{
26    free(data);
27}
28
29void Layer::Render(Scene *scene, int x, int y, int z)
30{
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);
36}
37
38int Layer::GetZ()
39{
40    return altitude;
41}
42
Note: See TracBrowser for help on using the repository browser.