if (!issolid(base.x + ((dir == LEFT) ? 0 : base.width),
base.y + base.height))
{
- physic.set_velocity_x(-physic.get_velocity_x());
if (dir == LEFT)
dir = RIGHT;
else
dir = LEFT;
+
+ physic.set_velocity_x(fabs(physic.get_velocity_x()) * dir == LEFT ? -1 : 1);
}
}
}
// Bounce off of other badguy if we land on top of him
if (base.y + base.height < pbad_c->base.y + pbad_c->base.height)
{
- Direction old_dir = dir;
if (pbad_c->dir == LEFT)
dir = RIGHT;
else if (pbad_c->dir == RIGHT)
dir = LEFT;
- if (dir != old_dir)
- physic.inverse_velocity_x();
-
- physic.set_velocity(fabs(physic.get_velocity_x()), 2);
+ physic.set_velocity(fabs(physic.get_velocity_x()) * dir == LEFT ? -1 : 1, 2);
break;
}
else if (dir == RIGHT)
dir = LEFT;
- physic.inverse_velocity_x();
+ physic.set_velocity_x(fabs(physic.get_velocity_x()) * dir == LEFT ? -1 : 1);
}
}