source: trunk/src/layer.cpp @ 664

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

Change the way the Scene object works.

  • Property svn:keywords set to Id
File size: 1.3 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <cstdlib>
16
17#include "core.h"
18
19Layer::Layer(int w, int h, int z, int o, uint32_t *in_data)
20{
21    width = w;
22    height = h;
23    altitude = z;
24    orientation = o;
25    data = in_data;
26
27#if 0
28    fread(data, sizeof(unsigned int), width * height, fp);
29    for (int n = 0; n < width * height; n++)
30    {
31        unsigned int i = data[n];
32        // XXX: endianness swapping might be necessary here
33        data[n] = i ? i - 1 : 0;
34    }
35#endif
36}
37
38Layer::~Layer()
39{
40    free(data);
41}
42
43void Layer::Render(int x, int y, int z)
44{
45    Scene *scene = Scene::GetDefault();
46    for (int j = 0; j < height; j++)
47        for (int i = 0; i < width; i++)
48            if (data[j * width + i])
49                scene->AddTile(data[j * width + i],
50                               x + i * 32, y + j * 32 - altitude,
51                               altitude + z, orientation);
52}
53
54int Layer::GetZ()
55{
56    return altitude;
57}
58
Note: See TracBrowser for help on using the repository browser.