From a2fcbfa7ecc2b4408e7784451a12b4c8f64942e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erkki=20Sepp=C3=A4l=C3=A4?= Date: Wed, 22 Oct 2014 21:52:04 +0300 Subject: [PATCH] Computer now knows how to dive --- computerplayer.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/computerplayer.lua b/computerplayer.lua index 36b43ca..8797f81 100644 --- a/computerplayer.lua +++ b/computerplayer.lua @@ -48,12 +48,19 @@ ComputerPlayer = Class{ if ang > math.pi - math.pi / 2 and ang < math.pi + math.pi / 2 then local needLift = self.plane.body:getY() > 400 + local needDive = self.plane.body:getY() < 200 if needLift then - if ang < math.pi + math.pi / 2 then + if ang < math.pi + math.pi / 4 then wantCw = true - elseif ang > math.pi + math.pi / 2 then + elseif ang > math.pi + math.pi / 4 then wantCcw = true 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 wantCcw = true elseif ang < math.pi then