finishing up: rotation

This commit is contained in:
nek0 2018-05-26 08:34:49 +02:00
parent 8a28d54795
commit 2761777ff9

View file

@ -21,7 +21,7 @@ import Data.Maybe
import System.Random (randomRIO)
import Linear
import Linear hiding (E)
import Foreign.C.Types (CFloat(..))
@ -56,8 +56,8 @@ loadMap = do
(inter, rps) <- liftIO $ placeInteriorIO mat imgmat exits gr
liftIO $ logIO A.Debug ("number of reachpoints: " ++ show (length rps))
let nnex = Prelude.filter (\p -> pointType p /= RoomExit) rps
liftIO $ A.logIO A.Debug $ "number of placed NPCs: " ++ show (length nnex)
npcposs <- placeNPCs inter mat rps gr 50 -- (length nnex)
liftIO $ A.logIO A.Debug $ "number of placed NPCs: " ++ show (length npcposs)
(nws, _) <- liftIO $ yieldSystemT (worldState ud) $ do
void $ createEntity $ newEntity
{ pos = Just (V2 20.5 20.5)
@ -188,21 +188,21 @@ updateMap :: Double -> Affection UserData ()
updateMap dt = do
let direction :: V2 Double -> Direction -> Direction
direction vel'@(V2 vr _) rot' = if sqrt (vel' `dot` vel') > 0
then toEnum (
then
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)
| xu < 22.5 = NE
| xu > 22.5 && xu < 67.5 = E
| xu > 67.5 && xu < 112.5 = SE
| xu > 112.5 && xu < 157.5 = S
| xu > 157.5 && xu < 202.5 = SW
| xu > 202.5 && xu < 247.5 = W
| xu > 247.5 && xu < 292.5 = NW
| xu > 292.5 && xu < 337.5 = N
| xu > 337.5 = NE
in d
else rot'
ud <- getAffection
(nws, _) <- liftIO $ yieldSystemT (worldState ud) $ do
@ -277,8 +277,7 @@ updateMap dt = do
)
(A.log A.Verbose (show lll ++ " " ++ show len) lll)
)
, rot = Set (A.log A.Debug ("dir: " ++ show (direction vel' rot'))
(direction vel' rot'))
, rot = Set (direction vel' rot')
}
return ent
updateNPCs