plane: added incomplete support for flipping
This commit is contained in:
parent
b7b6e10535
commit
b1002378c5
3 changed files with 36 additions and 4 deletions
|
@ -84,6 +84,7 @@ local max_motorPower = ENGINE_MAX
|
||||||
local head_area = 1.0
|
local head_area = 1.0
|
||||||
local plane_area = 10.0
|
local plane_area = 10.0
|
||||||
local motor_speed_ratio = 80.0
|
local motor_speed_ratio = 80.0
|
||||||
|
local flipping_speed = 1.0 / 0.5
|
||||||
|
|
||||||
local out_of_bounds_coeff_multiplier = 10.0
|
local out_of_bounds_coeff_multiplier = 10.0
|
||||||
|
|
||||||
|
@ -438,6 +439,26 @@ Plane = Class{
|
||||||
|
|
||||||
local motorEffort = (self.motorPower / (math.max(fwd_vel, 100) + 1) - 1) / 2 + 1
|
local motorEffort = (self.motorPower / (math.max(fwd_vel, 100) + 1) - 1) / 2 + 1
|
||||||
self.motorSound:setPitch(motorEffort * self.motorPower / ENGINE_MAX + 0.5)
|
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
|
||||||
|
if finished then
|
||||||
|
self.flipping = 1.0
|
||||||
|
end
|
||||||
|
if self.goingRight then
|
||||||
|
self.orientationAngle = 180 * self.flipping
|
||||||
|
else
|
||||||
|
self.orientationAngle = 180 + 180 * self.flipping
|
||||||
|
if self.orientationAngle >= 360 then
|
||||||
|
self.orientationAngle = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if finished then
|
||||||
|
self.goingRight = not self.goingRight
|
||||||
|
self.flipping = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
draw = function(self)
|
draw = function(self)
|
||||||
|
@ -485,5 +506,11 @@ Plane = Class{
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
flip = function(self, down)
|
||||||
|
if self.flipping == nil then
|
||||||
|
self.flipping = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,9 @@ Player = Class{
|
||||||
end,
|
end,
|
||||||
decelerate = function(down)
|
decelerate = function(down)
|
||||||
self.plane:decelerate(down)
|
self.plane:decelerate(down)
|
||||||
|
end,
|
||||||
|
flip = function(down)
|
||||||
|
self.plane:flip(down)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ KEYMAP = {
|
||||||
flip = 'i',
|
flip = 'i',
|
||||||
shoot = 'o',
|
shoot = 'o',
|
||||||
accelerate = 'j',
|
accelerate = 'j',
|
||||||
decelerate = 'm'
|
decelerate = 'm',
|
||||||
|
flip = ','
|
||||||
},
|
},
|
||||||
|
|
||||||
[2] = {
|
[2] = {
|
||||||
|
@ -25,7 +26,8 @@ KEYMAP = {
|
||||||
flip = 'q',
|
flip = 'q',
|
||||||
shoot = 'w',
|
shoot = 'w',
|
||||||
accelerate = 'x',
|
accelerate = 'x',
|
||||||
decelerate = 'z'
|
decelerate = 'z',
|
||||||
|
flip = 'a'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue