projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
This should definitively fix frames out of range.
[supertux.git]
/
lib
/
special
/
sprite.cpp
diff --git
a/lib/special/sprite.cpp
b/lib/special/sprite.cpp
index
8e80604
..
ac50b83
100644
(file)
--- a/
lib/special/sprite.cpp
+++ b/
lib/special/sprite.cpp
@@
-131,9
+131,6
@@
if(i == actions.end())
return;
}
action = i->second;
return;
}
action = i->second;
-
-if((int)frame >= get_frames())
- frame = 0;
}
void
}
void
@@
-173,7
+170,11
@@
void
Sprite::update()
{
if(animation_loops == 0)
Sprite::update()
{
if(animation_loops == 0)
+ {
+ if(frame >= get_frames() || frame < 0)
+ frame = 0;
return;
return;
+ }
float frame_inc = (action->fps/1000.0) * (SDL_GetTicks() - last_tick);
last_tick = SDL_GetTicks();
float frame_inc = (action->fps/1000.0) * (SDL_GetTicks() - last_tick);
last_tick = SDL_GetTicks();
@@
-185,9
+186,9
@@
else
if(animation_reversed)
{
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()
{ // last case can happen when not used reverse_animation()
+ float excedent = frame - 0;
frame = get_frames() - 1;
if(animation_loops > 0)
{
frame = get_frames() - 1;
if(animation_loops > 0)
{
@@
-205,9
+206,9
@@
if(animation_reversed)
}
else
{
}
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)
{
frame = 0;
if(animation_loops > 0)
{