diff --git a/src/Makefile.am b/src/Makefile.am index 51c69197..d62b2cd3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,7 +10,7 @@ liblol_a_SOURCES = \ world.cpp world.h sample.cpp sample.h sampler.cpp sampler.h \ text.cpp text.h emitter.cpp emitter.h numeric.h hash.cpp hash.h \ worldentity.cpp worldentity.h image.cpp image.h gradient.cpp gradient.h \ - platform.cpp platform.h \ + platform.cpp platform.h sprite.cpp sprite.h \ \ sdlapp.cpp sdlapp.h sdlinput.cpp sdlinput.h \ \ diff --git a/src/core.h b/src/core.h index 4e677434..63b116ae 100644 --- a/src/core.h +++ b/src/core.h @@ -38,6 +38,7 @@ #include "font.h" #include "gradient.h" #include "sample.h" +#include "sprite.h" #include "text.h" #include "tileset.h" #include "world.h" diff --git a/src/sprite.cpp b/src/sprite.cpp new file mode 100644 index 00000000..a25ab5b5 --- /dev/null +++ b/src/sprite.cpp @@ -0,0 +1,67 @@ +// +// Lol Engine +// +// Copyright: (c) 2010-2011 Sam Hocevar +// This program is free software; you can redistribute it and/or +// modify it under the terms of the Do What The Fuck You Want To +// Public License, Version 2, as published by Sam Hocevar. See +// http://sam.zoy.org/projects/COPYING.WTFPL for more details. +// + +#if defined HAVE_CONFIG_H +# include "config.h" +#endif + +#include "core.h" + +namespace lol +{ + +/* + * Sprite implementation class + */ + +class SpriteData +{ + friend class Sprite; + +private: + TileSet *tileset; + vec3 pos; + int id; +}; + +/* + * Public Sprite class + */ + +Sprite::Sprite(TileSet *tileset, int id) + : data(new SpriteData()) +{ + data->tileset = tileset; + data->pos = vec3(0); + data->id = id; +} + +void Sprite::TickGame(float deltams) +{ + Entity::TickGame(deltams); +} + +void Sprite::TickDraw(float deltams) +{ + Entity::TickDraw(deltams); + + vec3i pos = (vec3i)data->pos; + + Scene::GetDefault()->AddTile(data->tileset, data->id, pos, 0); +} + +Sprite::~Sprite() +{ + Tiler::Deregister(data->tileset); + delete data; +} + +} /* namespace lol */ + diff --git a/src/sprite.h b/src/sprite.h new file mode 100644 index 00000000..ae76c084 --- /dev/null +++ b/src/sprite.h @@ -0,0 +1,44 @@ +// +// Lol Engine +// +// Copyright: (c) 2010-2011 Sam Hocevar +// This program is free software; you can redistribute it and/or +// modify it under the terms of the Do What The Fuck You Want To +// Public License, Version 2, as published by Sam Hocevar. See +// http://sam.zoy.org/projects/COPYING.WTFPL for more details. +// + +// +// The Sprite class +// ---------------- +// + +#if !defined __LOL_SPRITE_H__ +#define __LOL_SPRITE_H__ + +#include "worldentity.h" +#include "tileset.h" + +namespace lol +{ + +class SpriteData; + +class Sprite : public WorldEntity +{ +public: + Sprite(TileSet *tileset, int id); + virtual ~Sprite(); + +protected: + virtual void TickGame(float deltams); + virtual void TickDraw(float deltams); + +private: + SpriteData *data; +}; + +} /* namespace lol */ + +#endif // __LOL_SPRITE_H__ +