diff --git a/src/Makefile.am b/src/Makefile.am index 52c00f75..d0fcc6bc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,7 +8,8 @@ libcommon_a_SOURCES = \ 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 \ 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` test_map_SOURCES = test-map.cpp sdlinput.cpp sdlinput.h diff --git a/src/debugsprite.cpp b/src/debugsprite.cpp new file mode 100644 index 00000000..591c5b36 --- /dev/null +++ b/src/debugsprite.cpp @@ -0,0 +1,64 @@ +// +// Deus Hax (working title) +// Copyright (c) 2010 Sam Hocevar +// + +#if defined HAVE_CONFIG_H +# include "config.h" +#endif + +#include + +#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; +} + diff --git a/src/debugsprite.h b/src/debugsprite.h new file mode 100644 index 00000000..9e00136e --- /dev/null +++ b/src/debugsprite.h @@ -0,0 +1,35 @@ +// +// Deus Hax (working title) +// Copyright (c) 2010 Sam Hocevar +// + +// +// 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__ + diff --git a/src/test-map.cpp b/src/test-map.cpp index 7e28d065..43782666 100644 --- a/src/test-map.cpp +++ b/src/test-map.cpp @@ -14,6 +14,7 @@ #include "sdlinput.h" #include "debugfps.h" +#include "debugsprite.h" #include "game.h" #include "ticker.h" #include "profiler.h" @@ -51,6 +52,7 @@ int main(int argc, char **argv) /* Register an input driver and some debug stuff */ new SdlInput(game); new DebugFps(); + new DebugSprite(game); while (!game->Finished()) {