source: trunk/deushax/debugsprite.cpp @ 792

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

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

  • Property svn:keywords set to Id
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 <cmath>
11
12#include "core.h"
13
14using namespace lol;
15
16#include "debugsprite.h"
17
18/*
19 * DebugSprite implementation class
20 */
21
22class DebugSpriteData
23{
24    friend class DebugSprite;
25
26private:
27    Game *game;
28    TileSet *tileset;
29    vec3 pos;
30};
31
32/*
33 * Public DebugSprite class
34 */
35
36DebugSprite::DebugSprite(Game *game)
37  : data(new DebugSpriteData())
38{
39    data->game = game;
40    Ticker::Ref(game);
41    data->tileset = Tiler::Register("deushax/art/test/character-dress.png",
42                                    32, 0, sqrtf(2));
43    data->pos = vec3(320, 206, 0);
44}
45
46void DebugSprite::TickGame(float deltams)
47{
48    Entity::TickGame(deltams);
49
50    vec3 move = deltams * (vec3)Input::GetAxis(0);
51    data->pos = data->pos + move * vec3(0.1f * sqrtf(2.0f), .1f, 0.1f);
52}
53
54void DebugSprite::TickDraw(float deltams)
55{
56    Entity::TickDraw(deltams);
57
58    vec3i pos = (vec3i)data->pos;
59
60    Scene::GetDefault()->AddTile(data->tileset, 31, pos + vec3i(-16, 0, 0), 1);
61    Scene::GetDefault()->AddTile(data->tileset, 15, pos + vec3i(-16, 0, 32), 1);
62}
63
64DebugSprite::~DebugSprite()
65{
66    Ticker::Unref(data->game);
67    Tiler::Deregister(data->tileset);
68    delete data;
69}
70
Note: See TracBrowser for help on using the repository browser.