module Graphics.FreeGame.Util (untickGame, randomness, degrees, radians, loadPictureFromFile) where
import Control.Monad.Free
import qualified Control.Monad.Trans.Free as T
import Graphics.FreeGame.Base
import Graphics.FreeGame.Data.Bitmap
import System.Random
untickGame :: Game a -> Game (Game a)
untickGame (Pure a) = Pure (Pure a)
untickGame (Free (Tick cont)) = Pure cont
untickGame (Free fm) = Free $ fmap untickGame fm
randomness :: (Random r, MonadFree GameAction m) => (r, r) -> m r
randomness r = embedIO $ randomRIO r
degrees :: Float -> Float
degrees x = x / pi * 180
radians :: Float -> Float
radians x = x / 180 * pi
loadPictureFromFile :: FilePath -> Game Picture
loadPictureFromFile = embedIO . fmap BitmapPicture . loadBitmapFromFile