source: trunk/src/debugboard.cpp @ 218

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

The Tile size can now be specified upon TileSet load. Add a sample
with the Monsterz tiles.

File size: 1.3 KB
Line 
1//
2// Deus Hax (working title)
3// Copyright (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
4//
5
6#if defined HAVE_CONFIG_H
7#   include "config.h"
8#endif
9
10#include <cstdio>
11#include <cmath>
12
13#include "core.h"
14#include "debugboard.h"
15
16/*
17 * DebugBoard implementation class
18 */
19
20class DebugBoardData
21{
22    friend class DebugBoard;
23
24private:
25    Game *game;
26    int tiler;
27    float x, y, z;
28};
29
30/*
31 * Public DebugBoard class
32 */
33
34DebugBoard::DebugBoard(Game *game)
35{
36    data = new DebugBoardData();
37    data->game = game;
38    Ticker::Ref(game);
39    data->tiler = Tiler::Register("monsterz/tiles.png", 48);
40    data->x = 32;
41    data->y = 0;
42    data->z = 112;
43}
44
45void DebugBoard::TickGame(float deltams)
46{
47    Entity::TickGame(deltams);
48}
49
50void DebugBoard::TickDraw(float deltams)
51{
52    Entity::TickDraw(deltams);
53
54    int x = data->x;
55    int y = data->y;
56    int z = data->z;
57
58    for (int j = 0; j < 8; j++)
59        for (int i = 0; i < 8; i++)
60    {
61        int id = 28 + ((i + 3) * (j + 1) % 10) * 3 + ((i ^ (j + 2)) % 5);
62        id += (id % 5) / 4;
63        data->game->GetScene()->AddTile((data->tiler << 16) | id,
64                                        x + i * 48 - 16, y + j * 48, z, 1);
65    }
66}
67
68DebugBoard::~DebugBoard()
69{
70    Ticker::Unref(data->game);
71    Tiler::Deregister(data->tiler);
72    delete data;
73}
74
Note: See TracBrowser for help on using the repository browser.