source: trunk/src/layer.cpp @ 38

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

Dynamically allocate layers when loading maps.

  • Property svn:keywords set to Id
File size: 491 bytes
Line 
1
2#include "layer.h"
3
4Layer::Layer(int w, int h, FILE *fp)
5{
6    width = w;
7    height = h;
8    data = new unsigned int[w * h];
9
10    fread(data, sizeof(unsigned int), width * height, fp);
11    for (int n = 0; n < width * height; n++)
12    {
13        unsigned int i = data[n];
14        // XXX: endianness swapping might be necessary here
15        data[n] = i ? i - 1 : 0;
16    }
17}
18
19Layer::~Layer()
20{
21    delete data;
22}
23
24unsigned int Layer::GetTile(int x, int y)
25{
26    return data[y * width + x];
27}
28
Note: See TracBrowser for help on using the repository browser.