}
void
-WalkingBadguy::active_update(float elapsed_time)
+WalkingBadguy::active_update(float elapsed_time, float dest_x_velocity)
{
BadGuy::active_update(elapsed_time);
float current_x_velocity = physic.get_velocity_x ();
- float dest_x_velocity = (dir == LEFT) ? -walk_speed : +walk_speed;
if (frozen)
{
physic.set_acceleration_x (0.0);
}
/* Check if we're going too slow or even in the wrong direction */
- else if (((dir == LEFT) && (current_x_velocity > dest_x_velocity))
- || ((dir == RIGHT) && (current_x_velocity < dest_x_velocity)))
+ else if (((dest_x_velocity <= 0.0) && (current_x_velocity > dest_x_velocity))
+ || ((dest_x_velocity > 0.0) && (current_x_velocity < dest_x_velocity)))
{
/* acceleration == walk-speed => it will take one second to get from zero
* to full speed. */
physic.set_acceleration_x (dest_x_velocity);
}
/* Check if we're going too fast */
- else if (((dir == LEFT) && (current_x_velocity < dest_x_velocity))
- || ((dir == RIGHT) && (current_x_velocity > dest_x_velocity)))
+ else if (((dest_x_velocity <= 0.0) && (current_x_velocity < dest_x_velocity))
+ || ((dest_x_velocity > 0.0) && (current_x_velocity > dest_x_velocity)))
{
/* acceleration == walk-speed => it will take one second to get twice the
* speed to normal speed. */
}
void
+WalkingBadguy::active_update(float elapsed_time)
+{
+ this->active_update (elapsed_time, (dir == LEFT) ? -walk_speed : +walk_speed);
+}
+
+void
WalkingBadguy::collision_solid(const CollisionHit& hit)
{
void initialize();
void active_update(float elapsed_time);
+ void active_update(float elapsed_time, float target_velocity);
void collision_solid(const CollisionHit& hit);
HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
void freeze();