fix direction
This commit is contained in:
parent
765e5e2549
commit
9c3e607d2b
1 changed files with 16 additions and 6 deletions
22
src/Test.hs
22
src/Test.hs
|
@ -186,13 +186,23 @@ drawMap = do
|
||||||
|
|
||||||
updateMap :: Double -> Affection UserData ()
|
updateMap :: Double -> Affection UserData ()
|
||||||
updateMap dt = do
|
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 (
|
then toEnum (
|
||||||
let xuu = floor
|
let xuu =
|
||||||
((((acos ((vel' `dot` V2 0 1) / sqrt (vel' `dot` vel'))) /
|
(acos ((vel' `dot` V2 0 1) / sqrt (vel' `dot` vel'))) / pi * 180
|
||||||
pi) + 0.25) * 4 )
|
xu = if vr < 0 then 360 - xuu else xuu
|
||||||
xu = if vr < 0 then 7 - xuu else xuu
|
d
|
||||||
in A.log A.Debug ("xu: " ++ show xu) xu)
|
| 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'
|
else rot'
|
||||||
ud <- getAffection
|
ud <- getAffection
|
||||||
(nws, _) <- liftIO $ yieldSystemT (worldState ud) $ do
|
(nws, _) <- liftIO $ yieldSystemT (worldState ud) $ do
|
||||||
|
|
Loading…
Reference in a new issue