source: trunk/src/layer.cpp @ 112

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

Slightly improve the documentation in a few files, add the missing
joystick class, and put a header in each source file.

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