2017-01-03 16:34:37 +00:00
|
|
|
{-# LANGUAGE RecordWildCards #-}
|
|
|
|
|
2016-12-31 16:01:24 +00:00
|
|
|
module Commons where
|
|
|
|
|
|
|
|
import Affection
|
|
|
|
import qualified SDL
|
|
|
|
import GEGL
|
|
|
|
import BABL
|
|
|
|
|
|
|
|
import qualified Data.Map as M
|
2017-01-03 16:34:37 +00:00
|
|
|
import Data.List (delete)
|
2017-12-16 10:55:30 +00:00
|
|
|
import Data.Maybe (catMaybes, isJust)
|
2016-12-31 16:01:24 +00:00
|
|
|
|
2017-12-16 10:55:30 +00:00
|
|
|
import Control.Monad (foldM, unless, when)
|
2016-12-31 16:01:24 +00:00
|
|
|
|
|
|
|
import System.Random (randomRIO)
|
|
|
|
|
|
|
|
import Debug.Trace
|
|
|
|
|
|
|
|
import Types
|
|
|
|
|
|
|
|
toR :: Double -> Double
|
|
|
|
toR deg = deg * pi / 180
|
|
|
|
|
2017-01-03 16:34:37 +00:00
|
|
|
wrapAround :: (Ord t, Num t) => (t, t) -> t -> (t, t)
|
|
|
|
wrapAround (nx, ny) width = (nnx, nny)
|
|
|
|
where
|
2017-01-03 18:36:01 +00:00
|
|
|
nnx
|
|
|
|
| nx > 800 = nx - (800 + width)
|
|
|
|
| nx < -width = nx + 800 + width
|
|
|
|
| otherwise = nx
|
|
|
|
nny
|
|
|
|
| ny > 600 = ny - (600 + width)
|
|
|
|
| ny < -width = ny + 600 + width
|
|
|
|
| otherwise = ny
|