fix direction

This commit is contained in:
nek0 2018-05-21 05:56:15 +02:00
parent 765e5e2549
commit 9c3e607d2b

View file

@ -186,13 +186,23 @@ drawMap = do
updateMap :: Double -> Affection UserData ()
updateMap dt = do
let direction vel'@(V2 vr _) rot' = if sqrt (vel' `dot` vel') > 0
let direction :: V2 Double -> Direction -> Direction
direction vel'@(V2 vr _) rot' = if sqrt (vel' `dot` vel') > 0
then toEnum (
let xuu = floor
((((acos ((vel' `dot` V2 0 1) / sqrt (vel' `dot` vel'))) /
pi) + 0.25) * 4 )
xu = if vr < 0 then 7 - xuu else xuu
in A.log A.Debug ("xu: " ++ show xu) xu)
let xuu =
(acos ((vel' `dot` V2 0 1) / sqrt (vel' `dot` vel'))) / pi * 180
xu = if vr < 0 then 360 - xuu else xuu
d
| xu < 22.5 = 0
| xu > 22.5 && xu < 67.5 = 1
| xu > 67.5 && xu < 112.5 = 2
| xu > 112.5 && xu < 157.5 = 3
| xu > 157.5 && xu < 202.5 = 4
| xu > 202.5 && xu < 247.5 = 5
| xu > 247.5 && xu < 292.5 = 6
| xu > 292.5 && xu < 337.5 = 7
| xu > 337.5 = 0
in d)
else rot'
ud <- getAffection
(nws, _) <- liftIO $ yieldSystemT (worldState ud) $ do