Update of /cvsroot/super-tux/supertux/lib/special
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30319/lib/special
Modified Files:
sprite.cpp sprite.h
Log Message:
Improvements.
Index: sprite.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/lib/special/sprite.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- sprite.cpp 14 Aug 2004 11:32:50 -0000 1.8
+++ sprite.cpp 14 Aug 2004 11:50:24 -0000 1.9
@@ -150,20 +150,20 @@
last_tick = SDL_GetTicks();
-if(!animation_reversed)
+if(animation_reversed)
{
- if((unsigned int)frame >= action->surfaces.size())
+ if((unsigned int)frame < 0)
{
- frame = 0;
+ frame = get_frames()-1;
if(animation_loops > 0)
animation_loops--;
}
}
else
{
- if((unsigned int)frame < 0)
+ if((unsigned int)frame >= action->surfaces.size())
{
- frame = get_frames()-1;
+ frame = 0;
if(animation_loops > 0)
animation_loops--;
}
@@ -176,8 +176,8 @@
{
update();
- if((int)frame >= get_frames())
- std::cerr << "Warning: frame higher than total frames!\n";
+ if((int)frame >= get_frames() || (int)frame < 0)
+ std::cerr << "Warning: frame higher than total frames or lower than 0!\n";
else
context.draw_surface(action->surfaces[(int)frame],
pos - Vector(action->x_hotspot, action->y_hotspot), layer, drawing_effect);
Index: sprite.h
===================================================================
RCS file: /cvsroot/super-tux/supertux/lib/special/sprite.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- sprite.h 14 Aug 2004 11:32:51 -0000 1.8
+++ sprite.h 14 Aug 2004 11:50:24 -0000 1.9
@@ -90,7 +90,7 @@
{ 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())
|