excluding ship position from new haskelloid generation

This commit is contained in:
nek0 2017-12-22 04:51:50 +01:00
parent 6bdc1acca3
commit 248043ba24

View file

@ -37,16 +37,16 @@ wrapAround (V2 nx ny) width = V2 nnx nny
half = width / 2 half = width / 2
newHaskelloids :: Affection UserData [Haskelloid] newHaskelloids :: Affection UserData [Haskelloid]
newHaskelloids = do newHaskelloids =
do
img <- haskImage <$> getAffection img <- haskImage <$> getAffection
liftIO $ mapM (\_ -> do liftIO $ mapM (\_ -> do
posx <- randomRIO (0, 800) div <- randomRIO (1, 2)
posy <- randomRIO (0, 600) (posx, posy) <- getCoordinates div
velx <- randomRIO (-10, 10) velx <- randomRIO (-10, 10)
vely <- randomRIO (-10, 10) vely <- randomRIO (-10, 10)
rot <- randomRIO (-180, 180) rot <- randomRIO (-180, 180)
pitch <- randomRIO (-pi, pi) pitch <- randomRIO (-pi, pi)
div <- randomRIO (1, 2)
return $ Haskelloid return $ Haskelloid
(V2 posx posy) (V2 posx posy)
(V2 velx vely) (V2 velx vely)
@ -55,6 +55,13 @@ newHaskelloids = do
div div
img img
) [1..10] ) [1..10]
where
getCoordinates div = do
posx <- randomRIO (0, 800)
posy <- randomRIO (0, 600)
if distance (V2 posx posy) (V2 400 300) < 20 + (50 / fromIntegral div)
then getCoordinates div
else return (posx, posy)
updateHaskelloid :: Double -> Haskelloid -> Haskelloid updateHaskelloid :: Double -> Haskelloid -> Haskelloid
updateHaskelloid dsec has = updateHaskelloid dsec has =