source: trunk/deushax/debugsprite.cpp @ 664

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

Get rid of float3, float4, int3 etc. in favour of GLSL types.

  • Property svn:keywords set to Id
File size: 1.3 KB
RevLine 
[132]1//
2// Deus Hax (working title)
[221]3// Copyright (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
[132]4//
5
6#if defined HAVE_CONFIG_H
7#   include "config.h"
8#endif
9
10#include <cstdio>
[151]11#include <cmath>
[132]12
[150]13#include "core.h"
[132]14#include "debugsprite.h"
15
16/*
17 * DebugSprite implementation class
18 */
19
20class DebugSpriteData
21{
22    friend class DebugSprite;
23
24private:
25    Game *game;
26    int tiler;
[664]27    vec3 pos;
[132]28};
29
30/*
31 * Public DebugSprite class
32 */
33
34DebugSprite::DebugSprite(Game *game)
[259]35  : data(new DebugSpriteData())
[132]36{
37    data->game = game;
[170]38    Ticker::Ref(game);
[222]39    data->tiler = Tiler::Register("art/test/character-dress.png",
[633]40                                  32, 0, sqrtf(2));
[664]41    data->pos = vec3(320, 206, 0);
[132]42}
43
[149]44void DebugSprite::TickGame(float deltams)
[132]45{
[149]46    Entity::TickGame(deltams);
[150]47
[664]48    vec3 move = deltams * (vec3)Input::GetAxis(0);
49    data->pos = data->pos + move * vec3(0.1f * sqrtf(2.0f), .1f, 0.1f);
[132]50}
51
[154]52void DebugSprite::TickDraw(float deltams)
[132]53{
[154]54    Entity::TickDraw(deltams);
[132]55
[664]56    vec3i pos = (vec3i)data->pos;
[150]57
[289]58    Scene::GetDefault()->AddTile((data->tiler << 16) | 31,
[295]59                                 pos.x - 16, pos.y, pos.z, 1);
[289]60    Scene::GetDefault()->AddTile((data->tiler << 16) | 15,
[295]61                                 pos.x - 16, pos.y, pos.z + 32, 1);
[132]62}
63
64DebugSprite::~DebugSprite()
65{
[170]66    Ticker::Unref(data->game);
[132]67    Tiler::Deregister(data->tiler);
68    delete data;
69}
70
Note: See TracBrowser for help on using the repository browser.