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()));
}
}
}
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();
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);
}
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()));
}
}