Computer now knows how to dive

This commit is contained in:
Erkki Seppälä 2014-10-22 21:52:04 +03:00
parent a4b6e7450f
commit a2fcbfa7ec

View file

@ -48,12 +48,19 @@ ComputerPlayer = Class{
if ang > math.pi - math.pi / 2 and if ang > math.pi - math.pi / 2 and
ang < math.pi + math.pi / 2 then ang < math.pi + math.pi / 2 then
local needLift = self.plane.body:getY() > 400 local needLift = self.plane.body:getY() > 400
local needDive = self.plane.body:getY() < 200
if needLift then if needLift then
if ang < math.pi + math.pi / 2 then if ang < math.pi + math.pi / 4 then
wantCw = true wantCw = true
elseif ang > math.pi + math.pi / 2 then elseif ang > math.pi + math.pi / 4 then
wantCcw = true wantCcw = true
end end
elseif needDive then
if ang < math.pi + math.pi / 4 then
wantCcw = true
elseif ang > math.pi + math.pi / 4 then
wantCw = true
end
elseif ang > math.pi then elseif ang > math.pi then
wantCcw = true wantCcw = true
elseif ang < math.pi then elseif ang < math.pi then