source: trunk/src/layer.cpp @ 792

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

tiler: ensure AddTile() and BlitTile() accept vec3i arguments.

  • Property svn:keywords set to Id
File size: 1.5 KB
RevLine 
[100]1//
[221]2// Lol Engine
[100]3//
[221]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//
[38]10
[100]11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
[141]15#include <cstdlib>
[75]16
[150]17#include "core.h"
[38]18
[758]19using namespace std;
20
[686]21namespace lol
22{
23
[133]24Layer::Layer(int w, int h, int z, int o, uint32_t *in_data)
[38]25{
26    width = w;
27    height = h;
[79]28    altitude = z;
[133]29    orientation = o;
[74]30    data = in_data;
[38]31
[70]32#if 0
[38]33    fread(data, sizeof(unsigned int), width * height, fp);
34    for (int n = 0; n < width * height; n++)
35    {
36        unsigned int i = data[n];
37        // XXX: endianness swapping might be necessary here
38        data[n] = i ? i - 1 : 0;
39    }
[70]40#endif
[38]41}
42
43Layer::~Layer()
44{
[75]45    free(data);
[38]46}
47
[289]48void Layer::Render(int x, int y, int z)
[75]49{
[790]50    Log::Error("FIXME: Layer::Render no longer works\n");
51#if 0
[289]52    Scene *scene = Scene::GetDefault();
[79]53    for (int j = 0; j < height; j++)
54        for (int i = 0; i < width; i++)
55            if (data[j * width + i])
[141]56                scene->AddTile(data[j * width + i],
[792]57                               vec3i(x + i * 32,
58                                     y + j * 32 - altitude,
59                                     altitude + z),
60                               orientation);
[790]61#endif
[75]62}
63
[47]64int Layer::GetZ()
65{
[79]66    return altitude;
[47]67}
68
[686]69} /* namespace lol */
70
Note: See TracBrowser for help on using the repository browser.