source: trunk/src/debugsprite.cpp @ 150

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

Replace mouse scrolling with a joystick simulated by the e/s/d/f keys.

  • Property svn:keywords set to Id
File size: 1.2 KB
Line 
1//
2// Deus Hax (working title)
3// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
4//
5
6#if defined HAVE_CONFIG_H
7#   include "config.h"
8#endif
9
10#include <cstdio>
11
12#include "core.h"
13#include "debugsprite.h"
14
15/*
16 * DebugSprite implementation class
17 */
18
19class DebugSpriteData
20{
21    friend class DebugSprite;
22
23private:
24    Game *game;
25    int tiler;
26    float x, y, z;
27};
28
29/*
30 * Public DebugSprite class
31 */
32
33DebugSprite::DebugSprite(Game *game)
34{
35    data = new DebugSpriteData();
36    data->game = game;
37    data->tiler = Tiler::Register("art/test/character-dress.png");
38    data->x = 320;
39    data->y = 206;
40    data->z = 0;
41}
42
43Entity::Group DebugSprite::GetGroup()
44{
45    return GROUP_DEFAULT;
46}
47
48void DebugSprite::TickGame(float deltams)
49{
50    Entity::TickGame(deltams);
51
52    Float2 axis = Input::GetAxis(0);
53    data->x += 0.1f * deltams * axis.x;
54    data->y += 0.1f * deltams * axis.y;
55}
56
57void DebugSprite::TickRender(float deltams)
58{
59    Entity::TickRender(deltams);
60
61    int x = data->x;
62    int y = data->y;
63    int z = data->z;
64
65    data->game->GetScene()->AddTile((data->tiler << 16) | 15, x, y, z + 32, 1);
66    data->game->GetScene()->AddTile((data->tiler << 16) | 31, x, y, z, 1);
67}
68
69DebugSprite::~DebugSprite()
70{
71    Tiler::Deregister(data->tiler);
72    delete data;
73}
74
Note: See TracBrowser for help on using the repository browser.