Browse Source

Add a debug sprite to the scene.

legacy
Sam Hocevar sam 14 years ago
parent
commit
e16f8d7804
4 changed files with 103 additions and 1 deletions
  1. +2
    -1
      src/Makefile.am
  2. +64
    -0
      src/debugsprite.cpp
  3. +35
    -0
      src/debugsprite.h
  4. +2
    -0
      src/test-map.cpp

+ 2
- 1
src/Makefile.am View File

@@ -8,7 +8,8 @@ libcommon_a_SOURCES = \
scene.cpp scene.h font.cpp font.h layer.cpp layer.h map.cpp map.h \ scene.cpp scene.h font.cpp font.h layer.cpp layer.h map.cpp map.h \
joystick.cpp joystick.h asset.cpp asset.h ticker.cpp ticker.h \ joystick.cpp joystick.h asset.cpp asset.h ticker.cpp ticker.h \
forge.cpp forge.h video.cpp video.h timer.cpp timer.h \ forge.cpp forge.h video.cpp video.h timer.cpp timer.h \
profiler.cpp profiler.h debugfps.cpp debugfps.h
profiler.cpp profiler.h \
debugfps.cpp debugfps.h debugsprite.cpp debugsprite.h
libcommon_a_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image` libcommon_a_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image`


test_map_SOURCES = test-map.cpp sdlinput.cpp sdlinput.h test_map_SOURCES = test-map.cpp sdlinput.cpp sdlinput.h


+ 64
- 0
src/debugsprite.cpp View File

@@ -0,0 +1,64 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdio>

#include "debugsprite.h"
#include "game.h"
#include "tiler.h"

/*
* DebugSprite implementation class
*/

class DebugSpriteData
{
friend class DebugSprite;

private:
Game *game;
int tiler;
int frame;
};

/*
* Public DebugSprite class
*/

DebugSprite::DebugSprite(Game *game)
{
data = new DebugSpriteData();
data->game = game;
data->tiler = Tiler::Register("art/test/character-dress.png");
}

Asset::Group DebugSprite::GetGroup()
{
return GROUP_DEFAULT;
}

void DebugSprite::TickGame(float delta_time)
{
Asset::TickGame(delta_time);
}

void DebugSprite::TickRender(float delta_time)
{
Asset::TickRender(delta_time);

data->game->GetScene()->AddTile((data->tiler << 16) | 15, 300, 200, 200);
data->game->GetScene()->AddTile((data->tiler << 16) | 31, 300, 232, 200);
}

DebugSprite::~DebugSprite()
{
Tiler::Deregister(data->tiler);
delete data;
}


+ 35
- 0
src/debugsprite.h View File

@@ -0,0 +1,35 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

//
// The DebugSprite class
// ---------------------
//

#if !defined __DH_DEBUGSPRITE_H__
#define __DH_DEBUGSPRITE_H__

#include "asset.h"
#include "game.h"

class DebugSpriteData;

class DebugSprite : public Asset
{
public:
DebugSprite(Game *game);
virtual ~DebugSprite();

protected:
virtual Group GetGroup();
virtual void TickGame(float delta_time);
virtual void TickRender(float delta_time);

private:
DebugSpriteData *data;
};

#endif // __DH_DEBUGSPRITE_H__


+ 2
- 0
src/test-map.cpp View File

@@ -14,6 +14,7 @@


#include "sdlinput.h" #include "sdlinput.h"
#include "debugfps.h" #include "debugfps.h"
#include "debugsprite.h"
#include "game.h" #include "game.h"
#include "ticker.h" #include "ticker.h"
#include "profiler.h" #include "profiler.h"
@@ -51,6 +52,7 @@ int main(int argc, char **argv)
/* Register an input driver and some debug stuff */ /* Register an input driver and some debug stuff */
new SdlInput(game); new SdlInput(game);
new DebugFps(); new DebugFps();
new DebugSprite(game);


while (!game->Finished()) while (!game->Finished())
{ {


Loading…
Cancel
Save