source: trunk/deushax/debugsprite.cpp @ 785

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

deushax: move everything DeusHax-related to its own subdirectory.

  • Property svn:keywords set to Id
File size: 1.4 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    int tiler;
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->tiler = 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->tiler << 16) | 31,
61                                 pos.x - 16, pos.y, pos.z, 1);
62    Scene::GetDefault()->AddTile((data->tiler << 16) | 15,
63                                 pos.x - 16, pos.y, pos.z + 32, 1);
64}
65
66DebugSprite::~DebugSprite()
67{
68    Ticker::Unref(data->game);
69    Tiler::Deregister(data->tiler);
70    delete data;
71}
72
Note: See TracBrowser for help on using the repository browser.