[Super-tux-commit] supertux/lib/special collision.cpp,1.5,1.6 sprite.cpp,1.33,1.34
Brought to you by:
wkendrick
From: Matze B. <mat...@us...> - 2004-11-26 13:56:49
|
Update of /cvsroot/super-tux/supertux/lib/special In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20618/lib/special Modified Files: collision.cpp sprite.cpp Log Message: fixed broken 1-time animations in sprites, fixed collision code returning no-collision if both objects didn't move, some cleanups Index: collision.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/collision.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- collision.cpp 25 Nov 2004 16:38:30 -0000 1.5 +++ collision.cpp 26 Nov 2004 13:56:30 -0000 1.6 @@ -38,7 +38,11 @@ hit.normal.y = 0; } else { if(movement.y > -DELTA && movement.y < DELTA) { - return false; + hit.time = 0; + hit.depth = 0; + hit.normal.x = 1; + hit.normal.y = 0; + return true; } hit.time = FLT_MAX; } Index: sprite.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- sprite.cpp 24 Nov 2004 23:10:02 -0000 1.33 +++ sprite.cpp 26 Nov 2004 13:56:30 -0000 1.34 @@ -57,7 +57,7 @@ return; SpriteData::Action* newaction = data.get_action(name); - if(!action) { + if(!newaction) { #ifdef DEBUG std::cerr << "Action '" << name << "' not found.\n"; #endif @@ -72,7 +72,7 @@ bool Sprite::check_animation() { - return animation_loops; + return animation_loops == 0; } void @@ -87,14 +87,12 @@ frame += frame_inc; - float lastframe = frame; - frame = fmodf(frame+get_frames(), get_frames()); - if(frame != lastframe) { - if(animation_loops > 0) { - animation_loops--; - if(animation_loops == 0) - frame = 0; - } + if(frame > get_frames()) { + frame = fmodf(frame+get_frames(), get_frames()); + + animation_loops--; + if(animation_loops == 0) + frame = 0; } } @@ -146,4 +144,3 @@ } -/* EOF */ |