X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=lib%2Fspecial%2Fsprite.h;h=e8b79374f9882aabc0763a40c9146ff3b69856df;hb=d88eb6fed051a3c6bea58857955ec5d902e63e04;hp=8de7d5cd40c05070810ca08f421ea22c0286be71;hpb=4b476ec30e7dd62249328054402d6493c20a685d;p=supertux.git diff --git a/lib/special/sprite.h b/lib/special/sprite.h index 8de7d5cd4..e8b79374f 100644 --- a/lib/special/sprite.h +++ b/lib/special/sprite.h @@ -22,6 +22,7 @@ #include #include +#include #include "../utils/lispreader.h" #include "../video/surface.h" @@ -33,23 +34,24 @@ namespace SuperTux class Sprite { private: - std::string name; - int x_hotspot; - int y_hotspot; + struct Action + { + std::string name; - /** Frames per second */ - float fps; + int x_hotspot; + int y_hotspot; - /** Number of seconds that a frame is displayed until it is switched - to the next frame */ - float frame_delay; + /** Frames per second */ + float fps; - float time; + /** Number of seconds that a frame is displayed until it is switched + to the next frame */ + float frame_delay; - std::vector surfaces; + std::vector surfaces; + }; - void init_defaults(); public: /** cur has to be a pointer to data in the form of ((x-hotspot 5) (y-hotspot 10) ...) */ @@ -64,13 +66,16 @@ namespace SuperTux Uint32 drawing_effect = NONE_EFFECT); int get_current_frame() const; + /** Set action (or state) */ + void set_action(std::string& act); + float get_fps() { - return fps; + return action->fps; } ; int get_frames() { - return surfaces.size(); + return action->surfaces.size(); } ; std::string get_name() const @@ -82,11 +87,23 @@ namespace SuperTux Surface* get_frame(unsigned int frame) { - if(frame < surfaces.size()) - return surfaces[frame]; + if(frame < action->surfaces.size()) + return action->surfaces[frame]; else - return surfaces[0]; - } + return action->surfaces[0]; + } + private: + void init_defaults(Action* act); + void parse_action(LispReader& lispreader); + + std::string name; + + float time; + + typedef std::map Actions; + Actions actions; + + Action* action; }; } //namespace SuperTux