From: Ryan Flegel Date: Thu, 6 May 2004 02:12:36 +0000 (+0000) Subject: - replaced some fabs() where fabsf() should be used X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e01b92b3fe0f0560074862aae9ac1a85a7951c02;p=supertux.git - replaced some fabs() where fabsf() should be used - made jumpy's animation follow the laws of physics more closely (springs) SVN-Revision: 1003 --- diff --git a/src/badguy.cpp b/src/badguy.cpp index 330c0dcbf..5e331585b 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -350,12 +350,12 @@ BadGuy::fall() if (dir == LEFT) { dir = RIGHT; - physic.set_velocity_x(fabs(physic.get_velocity_x())); + physic.set_velocity_x(fabsf(physic.get_velocity_x())); } else { dir = LEFT; - physic.set_velocity_x(-fabs(physic.get_velocity_x())); + physic.set_velocity_x(-fabsf(physic.get_velocity_x())); } } } @@ -376,12 +376,15 @@ BadGuy::remove_me() void BadGuy::action_jumpy(double frame_ratio) { - if (fabsf(physic.get_velocity_y()) < 2.5f) + const float vy = physic.get_velocity_y(); + + // XXX: These tests *should* use location from ground, not velocity + if (fabsf(vy) > 5.6f) + set_sprite(img_jumpy_left_down, img_jumpy_left_down); + else if (fabsf(vy) > 5.3f) set_sprite(img_jumpy_left_middle, img_jumpy_left_middle); - else if (physic.get_velocity_y() < 0) + else set_sprite(img_jumpy_left_up, img_jumpy_left_up); - else - set_sprite(img_jumpy_left_down, img_jumpy_left_down); Player& tux = *World::current()->get_tux(); @@ -1002,12 +1005,12 @@ BadGuy::collision(void *p_c_object, int c_object, CollisionType type) if (pbad_c->dir == LEFT) { dir = RIGHT; - physic.set_velocity(fabs(physic.get_velocity_x()), 2); + physic.set_velocity(fabsf(physic.get_velocity_x()), 2); } else if (pbad_c->dir == RIGHT) { dir = LEFT; - physic.set_velocity(-fabs(physic.get_velocity_x()), 2); + physic.set_velocity(-fabsf(physic.get_velocity_x()), 2); } @@ -1022,12 +1025,12 @@ BadGuy::collision(void *p_c_object, int c_object, CollisionType type) if (dir == LEFT) { dir = RIGHT; - physic.set_velocity_x(fabs(physic.get_velocity_x())); + physic.set_velocity_x(fabsf(physic.get_velocity_x())); } else if (dir == RIGHT) { dir = LEFT; - physic.set_velocity_x(-fabs(physic.get_velocity_x())); + physic.set_velocity_x(-fabsf(physic.get_velocity_x())); } }