source: trunk/deushax/debugsprite.cpp @ 1309

Last change on this file since 1309 was 1198, checked in by sam, 8 years ago

core: allow each blitted tile to be stretched differently.

  • Property svn:keywords set to Id
File size: 1.3 KB
Line 
1//
2// Deus Hax (working title)
3// Copyright (c) 2010-2012 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 std;
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    TileSet *tileset;
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->tileset = Tiler::Register("deushax/art/test/character-dress.png",
43                                    ivec2(32), ivec2(0));
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), 0.0f);
52    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    ivec3 pos = (ivec3)data->pos;
60
61    Scene::GetDefault()->AddTile(data->tileset, 31, pos + ivec3(-16, 0, 0), 1, vec2(1.0f));
62    Scene::GetDefault()->AddTile(data->tileset, 15, pos + ivec3(-16, 0, 32), 1, vec2(1.0f));
63}
64
65DebugSprite::~DebugSprite()
66{
67    Ticker::Unref(data->game);
68    Tiler::Deregister(data->tileset);
69    delete data;
70}
71
Note: See TracBrowser for help on using the repository browser.