4 // Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef SUPERTUX_SPRITE_H
21 #define SUPERTUX_SPRITE_H
27 #include "../utils/lispreader.h"
28 #include "../video/surface.h"
29 #include "../math/vector.h"
42 /** Position correction */
45 /** Drawing priority in queue */
48 /** Frames per second */
51 std::vector<Surface*> surfaces;
55 /** cur has to be a pointer to data in the form of ((x-offset 5)
57 Sprite(lisp_object_t* cur);
60 /** Draw sprite, automatically calculates next frame */
61 void draw(DrawingContext& context, const Vector& pos, int layer,
62 Uint32 drawing_effect = NONE_EFFECT);
64 void draw_part(DrawingContext& context, const Vector& source,
65 const Vector& size, const Vector& pos, int layer,
66 Uint32 drawing_effect = NONE_EFFECT);
68 /** Set action (or state) */
69 void set_action(std::string act);
74 1,2,3 - one, two, three times... */
75 void start_animation(int loops);
78 { start_animation(0); }
79 /** Check if animation is stopped or not */
80 bool check_animation();
81 /** Reverse the animation */
82 void reverse_animation(bool reverse);
85 { return action->fps; }
86 /** Get current action total frames */
88 { return action->surfaces.size(); }
89 /** Get sprite's name */
90 std::string get_name() const
92 /** Get current action name */
93 std::string get_action_name() const
94 { return action->name; }
98 /** Get current frame */
100 { return (int)frame; }
101 /** Set current frame */
102 void set_frame(int frame_)
103 { if(frame_ > get_frames()) frame = 0; else frame = frame_; }
104 Surface* get_frame(unsigned int frame)
106 if(frame < action->surfaces.size())
107 return action->surfaces[frame];
109 return action->surfaces[0];
112 void init_defaults(Action* act);
113 void parse_action(LispReader& lispreader);
122 bool animation_reversed;
125 typedef std::map <std::string, Action*> Actions;
129 std::string next_action;
132 } //namespace SuperTux
134 #endif /*SUPERTUX_SPRITE_H*/
136 /* Local Variables: */