source: trunk/src/layer.cpp @ 150

Last change on this file since 150 was 150, checked in by sam, 10 years ago

Replace mouse scrolling with a joystick simulated by the e/s/d/f keys.

  • Property svn:keywords set to Id
File size: 1.0 KB
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 <cstdlib>
11
12#include "core.h"
13
14Layer::Layer(int w, int h, int z, int o, uint32_t *in_data)
15{
16    width = w;
17    height = h;
18    altitude = z;
19    orientation = o;
20    data = in_data;
21
22#if 0
23    fread(data, sizeof(unsigned int), width * height, fp);
24    for (int n = 0; n < width * height; n++)
25    {
26        unsigned int i = data[n];
27        // XXX: endianness swapping might be necessary here
28        data[n] = i ? i - 1 : 0;
29    }
30#endif
31}
32
33Layer::~Layer()
34{
35    free(data);
36}
37
38void Layer::Render(Scene *scene, int x, int y, int z)
39{
40    for (int j = 0; j < height; j++)
41        for (int i = 0; i < width; i++)
42            if (data[j * width + i])
43                scene->AddTile(data[j * width + i],
44                               x + i * 32, y + j * 32 + altitude,
45                               altitude + z, orientation);
46}
47
48int Layer::GetZ()
49{
50    return altitude;
51}
52
Note: See TracBrowser for help on using the repository browser.