plane: when flipping, take speed and reversing into account
This commit is contained in:
parent
daa65d3fc2
commit
9611db61c8
1 changed files with 4 additions and 6 deletions
|
@ -84,7 +84,7 @@ local max_motorPower = ENGINE_MAX
|
|||
local head_area = 1.0
|
||||
local plane_area = 10.0
|
||||
local motor_speed_ratio = 80.0
|
||||
local flipping_speed = 1.0 / 0.5
|
||||
local flipping_speed = 1.0 / 0.5 / 500 -- 0.5 seconds at speed 500
|
||||
|
||||
local out_of_bounds_coeff_multiplier = 10.0
|
||||
|
||||
|
@ -443,8 +443,8 @@ Plane = Class{
|
|||
self.motorSound:setPitch(motorEffort * self.motorPower / ENGINE_MAX + 0.5)
|
||||
|
||||
if self.flipping ~= nil then
|
||||
self.flipping = self.flipping + flipping_speed * dt
|
||||
local finished = self.flipping >= 1.0
|
||||
self.flipping = self.flipping + flipping_speed * dt * fwd_vel
|
||||
local finished = self.flipping <= -1.0 or self.flipping >= 1.0
|
||||
if finished then
|
||||
self.flipping = 1.0
|
||||
end
|
||||
|
@ -452,10 +452,8 @@ Plane = Class{
|
|||
self.orientationAngle = 180 * self.flipping
|
||||
else
|
||||
self.orientationAngle = 180 + 180 * self.flipping
|
||||
if self.orientationAngle >= 360 then
|
||||
self.orientationAngle = 0
|
||||
end
|
||||
end
|
||||
self.orientationAngle = self.orientationAngle % 360
|
||||
if finished then
|
||||
self.goingRight = not self.goingRight
|
||||
self.flipping = nil
|
||||
|
|
Loading…
Reference in a new issue