source: trunk/deushax/debugsprite.cpp @ 686

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

Put everything in the "lol" namespace. Better late than never.

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