X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=lib%2Fspecial%2Fsprite.h;h=8239f49a0b144510b822c70a54860b706a5aa36d;hb=60e60d04f92c75700aaa9d9c9da4316176467dcf;hp=f84894582d40ea4a33b223b56ce47d0477945ca9;hpb=70f26d626c6e0f7717be209438341987ae38ddfc;p=supertux.git diff --git a/lib/special/sprite.h b/lib/special/sprite.h index f84894582..8239f49a0 100644 --- a/lib/special/sprite.h +++ b/lib/special/sprite.h @@ -39,18 +39,25 @@ namespace SuperTux { std::string name; - int x_hotspot; - int y_hotspot; + /** Position correction */ + int x_offset; + int y_offset; + /** Drawing priority in queue */ + int z_order; /** Frames per second */ float fps; + /** Mirror is used to avoid duplicating left and right side + sprites */ +// bool mirror; + std::vector surfaces; }; public: - /** cur has to be a pointer to data in the form of ((x-hotspot 5) - (y-hotspot 10) ...) */ + /** cur has to be a pointer to data in the form of ((x-offset 5) + (y-offset 10) ...) */ Sprite(lisp_object_t* cur); ~Sprite(); @@ -58,6 +65,10 @@ namespace SuperTux void draw(DrawingContext& context, const Vector& pos, int layer, Uint32 drawing_effect = NONE_EFFECT); + void draw_part(DrawingContext& context, const Vector& source, + const Vector& size, const Vector& pos, int layer, + Uint32 drawing_effect = NONE_EFFECT); + /** Set action (or state) */ void set_action(std::string act); @@ -66,10 +77,13 @@ namespace SuperTux 0 - stopped 1,2,3 - one, two, three times... */ void start_animation(int loops); + /* Stop animation */ + void stop_animation() + { start_animation(0); } /** Check if animation is stopped or not */ bool check_animation(); /** Reverse the animation */ - void reverse_animation(); + void reverse_animation(bool reverse); float get_fps() { return action->fps; } @@ -90,7 +104,7 @@ namespace SuperTux { return (int)frame; } /** Set current frame */ void set_frame(int frame_) - { frame = frame_; } + { if(frame_ > get_frames()) frame = 0; else frame = frame_; } Surface* get_frame(unsigned int frame) { if(frame < action->surfaces.size()) @@ -102,6 +116,9 @@ namespace SuperTux void init_defaults(Action* act); void parse_action(LispReader& lispreader); + /** Get an action */ + Action* get_action(std::string act); + void update(); void reset(); @@ -116,6 +133,7 @@ namespace SuperTux Actions actions; Action* action; + std::string next_action; }; } //namespace SuperTux