source: trunk/src/layer.cpp @ 75

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

Much better resource allocation and release. Scene manager stub.

  • Property svn:keywords set to Id
File size: 739 bytes
Line 
1
2#include <stdlib.h>
3
4#include "layer.h"
5
6Layer::Layer(int w, int h, int in_z, uint32_t *in_data)
7{
8    width = w;
9    height = h;
10    z = in_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::Draw()
30{
31    for (int y = 0; y < 32; y++)
32        for (int x = 0; x < 32; x++)
33            ;//tileset->AddTile(GetTile(x, y), x * 32, y * 32, z);
34}
35
36int Layer::GetZ()
37{
38    return z;
39}
40
41unsigned int Layer::GetTile(int x, int y)
42{
43    return data[y * width + x];
44}
45
Note: See TracBrowser for help on using the repository browser.