From 032f1d31132d67aa80d41c6eb7c642342f51b8e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erkki=20Sepp=C3=A4l=C3=A4?= Date: Tue, 21 Oct 2014 21:20:06 +0300 Subject: [PATCH] plane: instead of adding air friction when y is negative, do it only when also vel_y is negative --- entities/plane.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/entities/plane.lua b/entities/plane.lua index 2577281..f4c0eba 100644 --- a/entities/plane.lua +++ b/entities/plane.lua @@ -241,9 +241,14 @@ Plane = Class{ end local coeff_multiplier = 1 + local vel_x, vel_y = self.body:getLinearVelocity() + local abs_vel = VectorLight.len(vel_x, vel_y) + if self.body:getY() < 0 then self.motorPower = 0 - coeff_multiplier = out_of_bounds_coeff_multiplier + if vel_y < 0 then + coeff_multiplier = out_of_bounds_coeff_multiplier + end if not self.outOfBoundsArrow then self.outOfBoundsArrow = Arrow(0, 0, self.level, self.r, self.g, self.b) @@ -261,9 +266,6 @@ Plane = Class{ self.x, self.y = self.fixture:getBoundingBox() self.angle = self.body:getAngle() - local vel_x, vel_y = self.body:getLinearVelocity() - local abs_vel = VectorLight.len(vel_x, vel_y) - if self.accelerating then self.motorPower = math.min(max_motorPower, self.motorPower + dt * accel_speed) end