| @@ -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 | ||||
| @@ -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; | |||||
| } | |||||
| @@ -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__ | |||||
| @@ -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()) | ||||
| { | { | ||||