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"
45 /** Frames per second */
48 std::vector<Surface*> surfaces;
52 /** cur has to be a pointer to data in the form of ((x-hotspot 5)
53 (y-hotspot 10) ...) */
54 Sprite(lisp_object_t* cur);
57 /** Draw sprite, automatically calculates next frame */
58 void draw(DrawingContext& context, const Vector& pos, int layer,
59 Uint32 drawing_effect = NONE_EFFECT);
61 /** Set action (or state) */
62 void set_action(std::string act);
67 1,2,3 - one, two, three times... */
68 void start_animation(int loops);
69 /** Check if animation is stopped or not */
70 bool check_animation();
71 /** Reverse the animation */
72 void reverse_animation();
75 { return action->fps; }
76 /** Get current action total frames */
78 { return action->surfaces.size(); }
79 /** Get sprite's name */
80 std::string get_name() const
82 /** Get current action name */
83 std::string get_action_name() const
84 { return action->name; }
88 /** Get current frame */
90 { return (int)frame; }
91 /** Set current frame */
92 void set_frame(int frame_)
93 { if(frame_ > get_frames()) frame = 0; else frame = frame_; }
94 Surface* get_frame(unsigned int frame)
96 if(frame < action->surfaces.size())
97 return action->surfaces[frame];
99 return action->surfaces[0];
102 void init_defaults(Action* act);
103 void parse_action(LispReader& lispreader);
112 bool animation_reversed;
115 typedef std::map <std::string, Action*> Actions;
119 std::string next_action;
122 } //namespace SuperTux
124 #endif /*SUPERTUX_SPRITE_H*/
126 /* Local Variables: */