Update of /cvsroot/super-tux/supertux/lib/special
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv902/lib/special
Modified Files:
sprite.cpp
Log Message:
This should definitively fix frames out of range.
Index: sprite.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/lib/special/sprite.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- sprite.cpp 8 Sep 2004 13:59:09 -0000 1.23
+++ sprite.cpp 8 Sep 2004 14:12:48 -0000 1.24
@@ -170,7 +170,11 @@
Sprite::update()
{
if(animation_loops == 0)
+ {
+ if(frame >= get_frames() || frame < 0)
+ frame = 0;
return;
+ }
float frame_inc = (action->fps/1000.0) * (SDL_GetTicks() - last_tick);
last_tick = SDL_GetTicks();
@@ -182,9 +186,9 @@
if(animation_reversed)
{
- float excedent = frame - 0;
- if((int)excedent < 0 || excedent >= get_frames())
+ if(frame < 0 || frame >= (float)get_frames())
{ // last case can happen when not used reverse_animation()
+ float excedent = frame - 0;
frame = get_frames() - 1;
if(animation_loops > 0)
{
@@ -202,9 +206,9 @@
}
else
{
- float excedent = frame - (get_frames()+1);
- if((int)excedent >= 0)
+ if(frame >= (float)get_frames())
{
+ float excedent = frame - get_frames();
frame = 0;
if(animation_loops > 0)
{
|