{-# LANGUAGE CPP #-}
{-# OPTIONS_HADDOCK hide #-}
module Graphics.UI.Fungen.Game (
Game, IOGame,
createGame,
runIOGame, runIOGameM, liftIOtoIOGame, liftIOtoIOGame',
getGameState, setGameState,
getGameAttribute, setGameAttribute,
getGameFlags, setGameFlags,
enableGameFlags, disableGameFlags,
enableMapDrawing, disableMapDrawing,
enableObjectsDrawing, disableObjectsDrawing,
enableObjectsMoving, disableObjectsMoving,
drawMap, clearScreen, getTileFromIndex, getTileFromWindowPosition, setCurrentMapIndex,
getObjectManagers, setObjectManagers,
drawAllObjects, drawObject, moveAllObjects, destroyObjects, destroyObject,
getObjectsFromGroup, addObjectsToGroup, addObjectsToNewGroup, findObjectManager,findObject,
getObjectName, getObjectGroupName, getObjectAsleep, getObjectSize,
getObjectPosition, getObjectSpeed, getObjectAttribute,
setObjectPosition, setObjectAsleep, setObjectSpeed, setObjectCurrentPicture, setObjectAttribute,
replaceObject,
reverseXSpeed, reverseYSpeed,
objectsCollision, objectsFutureCollision,
objectListObjectCollision, objectListObjectFutureCollision,
objectTopMapCollision, objectBottomMapCollision, objectRightMapCollision, objectLeftMapCollision,
pointsObjectCollision, pointsObjectListCollision,
objectTopMapFutureCollision, objectBottomMapFutureCollision, objectRightMapFutureCollision, objectLeftMapFutureCollision,
printOnPrompt, printOnScreen, printText,
randomFloat, randomInt, randomDouble,
showFPS,
wait
) where
import Graphics.UI.Fungen.Types
import Graphics.UI.Fungen.Util
import Graphics.UI.Fungen.Loader
import Graphics.UI.Fungen.Text
import Graphics.UI.Fungen.Map
import Graphics.UI.Fungen.Objects
import Graphics.Rendering.OpenGL
import Graphics.UI.GLUT
import Control.Monad
import Data.IORef
import Text.Printf
data Game t s u v = Game {
forall t s u v. Game t s u v -> IORef (GameMap v)
gameMap :: IORef (GameMap v),
forall t s u v. Game t s u v -> IORef u
gameState :: IORef u,
forall t s u v. Game t s u v -> IORef GameFlags
gameFlags :: IORef GameFlags,
forall t s u v. Game t s u v -> IORef [ObjectManager s]
objManagers :: IORef [ObjectManager s],
forall t s u v. Game t s u v -> IORef [Text]
textList :: IORef [Text],
forall t s u v. Game t s u v -> QuadricPrimitive
quadricObj :: QuadricPrimitive,
forall t s u v. Game t s u v -> IORef WindowConfig
windowConfig :: IORef WindowConfig,
forall t s u v. Game t s u v -> IORef t
gameAttribute :: IORef t,
forall t s u v. Game t s u v -> IORef [TextureObject]
pictureList :: IORef [TextureObject],
forall t s u v. Game t s u v -> IORef (Int, Int, Float)
fpsInfo :: IORef (Int,Int,Float)
}
newtype IOGame t s u v a = IOG (Game t s u v -> IO (Game t s u v,a))
type GameFlags = (Bool,Bool,Bool)
bindST :: IOGame t s u v a -> (a -> IOGame t s u v b) -> IOGame t s u v b
bindST :: forall t s u v a b.
IOGame t s u v a -> (a -> IOGame t s u v b) -> IOGame t s u v b
bindST (IOG Game t s u v -> IO (Game t s u v, a)
x) a -> IOGame t s u v b
f =
forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG (Game t s u v -> IO (Game t s u v, a)
x forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (\ (Game t s u v
s', a
v) -> let IOG Game t s u v -> IO (Game t s u v, b)
g = a -> IOGame t s u v b
f a
v in Game t s u v -> IO (Game t s u v, b)
g Game t s u v
s'))
unitST :: a -> IOGame t s u v a
unitST :: forall a t s u v. a -> IOGame t s u v a
unitST a
v = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG (\Game t s u v
s -> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
s,a
v))
instance Functor (IOGame t s u v) where
fmap :: forall a b. (a -> b) -> IOGame t s u v a -> IOGame t s u v b
fmap = forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM
instance Applicative (IOGame t s u v) where
pure :: forall a. a -> IOGame t s u v a
pure = forall a t s u v. a -> IOGame t s u v a
unitST
<*> :: forall a b.
IOGame t s u v (a -> b) -> IOGame t s u v a -> IOGame t s u v b
(<*>) = forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
ap
instance Monad (IOGame t s u v) where
>>= :: forall a b.
IOGame t s u v a -> (a -> IOGame t s u v b) -> IOGame t s u v b
(>>=) = forall t s u v a b.
IOGame t s u v a -> (a -> IOGame t s u v b) -> IOGame t s u v b
bindST
instance MonadFail (IOGame t s u v) where
fail :: forall a. String -> IOGame t s u v a
fail String
s = forall a t s u v. IO a -> IOGame t s u v a
liftIOtoIOGame (forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
s)
runIOGame :: IOGame t s u v a -> Game t s u v -> IO (Game t s u v,a)
runIOGame :: forall t s u v a.
IOGame t s u v a -> Game t s u v -> IO (Game t s u v, a)
runIOGame (IOG Game t s u v -> IO (Game t s u v, a)
f) = Game t s u v -> IO (Game t s u v, a)
f
runIOGameM :: IOGame t s u v a -> Game t s u v -> IO ()
runIOGameM :: forall t s u v a. IOGame t s u v a -> Game t s u v -> IO ()
runIOGameM IOGame t s u v a
x Game t s u v
g = forall (f :: * -> *) a. Functor f => f a -> f ()
void (forall t s u v a.
IOGame t s u v a -> Game t s u v -> IO (Game t s u v, a)
runIOGame IOGame t s u v a
x Game t s u v
g)
liftIOtoIOGame :: IO a -> IOGame t s u v a
liftIOtoIOGame :: forall a t s u v. IO a -> IOGame t s u v a
liftIOtoIOGame IO a
p =
forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG forall a b. (a -> b) -> a -> b
$ \Game t s u v
s -> (do a
y <- IO a
p
forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
s,a
y))
liftIOtoIOGame' :: (a -> IO ()) -> a -> IOGame t s u v ()
liftIOtoIOGame' :: forall a t s u v. (a -> IO ()) -> a -> IOGame t s u v ()
liftIOtoIOGame' a -> IO ()
p a
q =
forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG forall a b. (a -> b) -> a -> b
$ \Game t s u v
s -> (do a -> IO ()
p a
q
forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
s,()))
getMap :: IOGame t s u v (GameMap v)
getMap :: forall t s u v. IOGame t s u v (GameMap v)
getMap = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall a. IORef a -> IO a
readIORef (forall t s u v. Game t s u v -> IORef (GameMap v)
gameMap Game t s u v
game) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \GameMap v
gm -> if forall t. GameMap t -> Bool
isMultiMap GameMap v
gm
then forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,forall t. GameMap t -> GameMap t
getCurrentMap GameMap v
gm)
else forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,GameMap v
gm))
getRealMap :: IOGame t s u v (GameMap v)
getRealMap :: forall t s u v. IOGame t s u v (GameMap v)
getRealMap = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall a. IORef a -> IO a
readIORef (forall t s u v. Game t s u v -> IORef (GameMap v)
gameMap Game t s u v
game) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \GameMap v
gm -> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,GameMap v
gm))
setRealMap :: GameMap v -> IOGame t s u v ()
setRealMap :: forall v t s u. GameMap v -> IOGame t s u v ()
setRealMap GameMap v
m = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall a. IORef a -> a -> IO ()
writeIORef (forall t s u v. Game t s u v -> IORef (GameMap v)
gameMap Game t s u v
game) GameMap v
m forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,()))
getGameState :: IOGame t s u v u
getGameState :: forall t s u v. IOGame t s u v u
getGameState = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall a. IORef a -> IO a
readIORef (forall t s u v. Game t s u v -> IORef u
gameState Game t s u v
game) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \u
gs -> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,u
gs))
setGameState :: u -> IOGame t s u v ()
setGameState :: forall u t s v. u -> IOGame t s u v ()
setGameState u
s = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall a. IORef a -> a -> IO ()
writeIORef (forall t s u v. Game t s u v -> IORef u
gameState Game t s u v
game) u
s forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,()))
getTextList :: IOGame t s u v [Text]
getTextList :: forall t s u v. IOGame t s u v [Text]
getTextList = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall a. IORef a -> IO a
readIORef (forall t s u v. Game t s u v -> IORef [Text]
textList Game t s u v
game) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Text]
tl -> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,[Text]
tl))
setTextList :: [Text] -> IOGame t s u v ()
setTextList :: forall t s u v. [Text] -> IOGame t s u v ()
setTextList [Text]
t = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall a. IORef a -> a -> IO ()
writeIORef (forall t s u v. Game t s u v -> IORef [Text]
textList Game t s u v
game) [Text]
t forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,()))
getGameFlags :: IOGame t s u v GameFlags
getGameFlags :: forall t s u v. IOGame t s u v GameFlags
getGameFlags = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall a. IORef a -> IO a
readIORef (forall t s u v. Game t s u v -> IORef GameFlags
gameFlags Game t s u v
game) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \GameFlags
gf -> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,GameFlags
gf))
setGameFlags :: GameFlags -> IOGame t s u v ()
setGameFlags :: forall t s u v. GameFlags -> IOGame t s u v ()
setGameFlags GameFlags
f = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall a. IORef a -> a -> IO ()
writeIORef (forall t s u v. Game t s u v -> IORef GameFlags
gameFlags Game t s u v
game) GameFlags
f forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,()))
getObjectManagers :: IOGame t s u v [ObjectManager s]
getObjectManagers :: forall t s u v. IOGame t s u v [ObjectManager s]
getObjectManagers = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall a. IORef a -> IO a
readIORef (forall t s u v. Game t s u v -> IORef [ObjectManager s]
objManagers Game t s u v
game) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[ObjectManager s]
om -> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,[ObjectManager s]
om))
setObjectManagers :: [ObjectManager s] -> IOGame t s u v ()
setObjectManagers :: forall s t u v. [ObjectManager s] -> IOGame t s u v ()
setObjectManagers [ObjectManager s]
o = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall a. IORef a -> a -> IO ()
writeIORef (forall t s u v. Game t s u v -> IORef [ObjectManager s]
objManagers Game t s u v
game) [ObjectManager s]
o forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,()))
getQuadric :: IOGame t s u v QuadricPrimitive
getQuadric :: forall t s u v. IOGame t s u v QuadricPrimitive
getQuadric = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,forall t s u v. Game t s u v -> QuadricPrimitive
quadricObj Game t s u v
game) )
getPictureList :: IOGame t s u v [TextureObject]
getPictureList :: forall t s u v. IOGame t s u v [TextureObject]
getPictureList = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall a. IORef a -> IO a
readIORef (forall t s u v. Game t s u v -> IORef [TextureObject]
pictureList Game t s u v
game) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[TextureObject]
pl -> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,[TextureObject]
pl))
getWindowConfig :: IOGame t s u v WindowConfig
getWindowConfig :: forall t s u v. IOGame t s u v WindowConfig
getWindowConfig = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall a. IORef a -> IO a
readIORef (forall t s u v. Game t s u v -> IORef WindowConfig
windowConfig Game t s u v
game) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \WindowConfig
wc -> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,WindowConfig
wc))
getGameAttribute :: IOGame t s u v t
getGameAttribute :: forall t s u v. IOGame t s u v t
getGameAttribute = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall a. IORef a -> IO a
readIORef (forall t s u v. Game t s u v -> IORef t
gameAttribute Game t s u v
game) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \t
ga -> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,t
ga))
setGameAttribute :: t -> IOGame t s u v ()
setGameAttribute :: forall t s u v. t -> IOGame t s u v ()
setGameAttribute t
ga = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall a. IORef a -> a -> IO ()
writeIORef (forall t s u v. Game t s u v -> IORef t
gameAttribute Game t s u v
game) t
ga forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,()))
getFpsInfo :: IOGame t s u v (Int,Int,Float)
getFpsInfo :: forall t s u v. IOGame t s u v (Int, Int, Float)
getFpsInfo = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall a. IORef a -> IO a
readIORef (forall t s u v. Game t s u v -> IORef (Int, Int, Float)
fpsInfo Game t s u v
game) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Int, Int, Float)
fpsi -> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,(Int, Int, Float)
fpsi))
setFpsInfo :: (Int,Int,Float) -> IOGame t s u v ()
setFpsInfo :: forall t s u v. (Int, Int, Float) -> IOGame t s u v ()
setFpsInfo (Int, Int, Float)
f = forall t s u v a.
(Game t s u v -> IO (Game t s u v, a)) -> IOGame t s u v a
IOG ( \Game t s u v
game -> forall a. IORef a -> a -> IO ()
writeIORef (forall t s u v. Game t s u v -> IORef (Int, Int, Float)
fpsInfo Game t s u v
game) (Int, Int, Float)
f forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return (Game t s u v
game,()))
createGame :: GameMap v -> [ObjectManager s] -> WindowConfig -> u -> t -> FilePictureList -> IO (Game t s u v)
createGame :: forall v s u t.
GameMap v
-> [ObjectManager s]
-> WindowConfig
-> u
-> t
-> FilePictureList
-> IO (Game t s u v)
createGame GameMap v
gMap [ObjectManager s]
objectManagers WindowConfig
winConf u
gState t
gAttrib FilePictureList
filePicList = do
IORef (GameMap v)
gM <- forall a. a -> IO (IORef a)
newIORef GameMap v
gMap
IORef u
gS <- forall a. a -> IO (IORef a)
newIORef u
gState
IORef GameFlags
gF <- forall a. a -> IO (IORef a)
newIORef (Bool
True,Bool
True,Bool
True)
IORef [ObjectManager s]
gO <- forall a. a -> IO (IORef a)
newIORef [ObjectManager s]
objectManagers
IORef [Text]
gT <- forall a. a -> IO (IORef a)
newIORef []
let gQ :: QuadricPrimitive
gQ = Radius -> Slices -> Slices -> QuadricPrimitive
Sphere Radius
0 Slices
0 Slices
0
IORef WindowConfig
gW <- forall a. a -> IO (IORef a)
newIORef WindowConfig
winConf
IORef t
gA <- forall a. a -> IO (IORef a)
newIORef t
gAttrib
[TextureObject]
picList <- FilePictureList -> IO [TextureObject]
loadPictures FilePictureList
filePicList
IORef [TextureObject]
gP <- forall a. a -> IO (IORef a)
newIORef [TextureObject]
picList
IORef (Int, Int, Float)
gFPS <- forall a. a -> IO (IORef a)
newIORef (Int
0,Int
0,Float
0.0)
forall (m :: * -> *) a. Monad m => a -> m a
return (Game {
gameMap :: IORef (GameMap v)
gameMap = IORef (GameMap v)
gM,
gameState :: IORef u
gameState = IORef u
gS,
gameFlags :: IORef GameFlags
gameFlags = IORef GameFlags
gF,
objManagers :: IORef [ObjectManager s]
objManagers = IORef [ObjectManager s]
gO,
textList :: IORef [Text]
textList = IORef [Text]
gT,
quadricObj :: QuadricPrimitive
quadricObj = QuadricPrimitive
gQ,
windowConfig :: IORef WindowConfig
windowConfig = IORef WindowConfig
gW,
gameAttribute :: IORef t
gameAttribute = IORef t
gA,
pictureList :: IORef [TextureObject]
pictureList = IORef [TextureObject]
gP,
fpsInfo :: IORef (Int, Int, Float)
fpsInfo = IORef (Int, Int, Float)
gFPS
})
loadPictures :: [(FilePath,InvList)] -> IO [TextureObject]
loadPictures :: FilePictureList -> IO [TextureObject]
loadPictures FilePictureList
pathsAndInvLists = do
[AwbfBitmap]
bmps <- [(String, Maybe ColorList3)] -> IO [AwbfBitmap]
loadBitmapList (forall a b. (a -> b) -> [a] -> [b]
map (String, InvList) -> (String, Maybe ColorList3)
pathAndInv2color3List FilePictureList
pathsAndInvLists)
[TextureObject]
texBmList <- forall a (m :: * -> *).
(GeneratableObjectName a, MonadIO m) =>
Int -> m [a]
genObjectNames (forall (t :: * -> *) a. Foldable t => t a -> Int
length [AwbfBitmap]
bmps)
[TextureObject] -> [AwbfBitmap] -> IO ()
texStuff [TextureObject]
texBmList [AwbfBitmap]
bmps
forall (m :: * -> *) a. Monad m => a -> m a
return [TextureObject]
texBmList
drawMap :: IOGame t s u v ()
drawMap :: forall t s u v. IOGame t s u v ()
drawMap = do
GameMap v
m <- forall t s u v. IOGame t s u v (GameMap v)
getMap
[TextureObject]
p <- forall t s u v. IOGame t s u v [TextureObject]
getPictureList
((Int, Int)
_,(Int
winWidth, Int
winHeight),String
_) <- forall t s u v. IOGame t s u v WindowConfig
getWindowConfig
forall a t s u v. IO a -> IOGame t s u v a
liftIOtoIOGame forall a b. (a -> b) -> a -> b
$ forall t. GameMap t -> Point2D -> [TextureObject] -> IO ()
drawGameMap GameMap v
m (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
winWidth, forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
winHeight) [TextureObject]
p
getTileFromWindowPosition :: (GLdouble,GLdouble) -> IOGame t s u v (Tile v)
getTileFromWindowPosition :: forall t s u v. Point2D -> IOGame t s u v (Tile v)
getTileFromWindowPosition (Radius
preX,Radius
preY) = do
GameMap v
m <- forall t s u v. IOGame t s u v (GameMap v)
getMap
if forall t. GameMap t -> Bool
isTileMap GameMap v
m
then let (Radius
tileXsize,Radius
tileYsize) = forall t. GameMap t -> Point2D
getTileMapTileSize GameMap v
m
(Radius
scrollX,Radius
scrollY) = forall t. GameMap t -> Point2D
getTileMapScroll GameMap v
m
(Radius
x,Radius
y) = (Radius
preX forall a. Num a => a -> a -> a
+ Radius
scrollX,Radius
preY forall a. Num a => a -> a -> a
+ Radius
scrollY)
(Radius
sX,Radius
sY) = forall t. GameMap t -> Point2D
getTileMapSize GameMap v
m
in if Radius
x forall a. Ord a => a -> a -> Bool
>= Radius
sX Bool -> Bool -> Bool
|| Radius
y forall a. Ord a => a -> a -> Bool
>= Radius
sY
then forall a. HasCallStack => String -> a
error (String
"Game.getTileFromWindowPosition error: pixel " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (Radius
x,Radius
y) forall a. [a] -> [a] -> [a]
++ String
" out of map range!")
else forall t s u v. (Int, Int) -> IOGame t s u v (Tile v)
getTileFromIndex (forall a. Enum a => a -> Int
fromEnum (Radius
yforall a. Fractional a => a -> a -> a
/Radius
tileXsize),forall a. Enum a => a -> Int
fromEnum (Radius
xforall a. Fractional a => a -> a -> a
/Radius
tileYsize))
else forall a. HasCallStack => String -> a
error String
"Game.getTileFromWindowPosition error: game map is not a tile map!"
getTileFromIndex :: (Int,Int) -> IOGame t s u v (Tile v)
getTileFromIndex :: forall t s u v. (Int, Int) -> IOGame t s u v (Tile v)
getTileFromIndex (Int
x,Int
y) = do
GameMap v
m <- forall t s u v. IOGame t s u v (GameMap v)
getMap
if forall t. GameMap t -> Bool
isTileMap GameMap v
m
then let matrix :: TileMatrix v
matrix = forall t. GameMap t -> TileMatrix t
getTileMapTileMatrix GameMap v
m
(Int
mapX,Int
mapY) = forall a. [[a]] -> (Int, Int)
matrixSize TileMatrix v
matrix
in if Int
mapX forall a. Ord a => a -> a -> Bool
>= Int
x Bool -> Bool -> Bool
&& Int
mapY forall a. Ord a => a -> a -> Bool
>= Int
y Bool -> Bool -> Bool
&& Int
x forall a. Ord a => a -> a -> Bool
>= Int
0 Bool -> Bool -> Bool
&& Int
y forall a. Ord a => a -> a -> Bool
>= Int
0
then forall (m :: * -> *) a. Monad m => a -> m a
return ( TileMatrix v
matrix forall a. [a] -> Int -> a
!! (Int
mapX forall a. Num a => a -> a -> a
- Int
x) forall a. [a] -> Int -> a
!! Int
y)
else forall a. HasCallStack => String -> a
error (String
"Game.getTileFromIndex error: tile index " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (Int
x,Int
y) forall a. [a] -> [a] -> [a]
++ String
" out of map range!")
else forall a. HasCallStack => String -> a
error String
"Game.getTileFromIndex error: game map is not a tile map!"
clearScreen :: GLclampf -> GLclampf -> GLclampf -> IOGame t s u v ()
clearScreen :: forall t s u v. Float -> Float -> Float -> IOGame t s u v ()
clearScreen Float
r Float
g Float
b = forall a t s u v. IO a -> IOGame t s u v a
liftIOtoIOGame forall a b. (a -> b) -> a -> b
$ Float -> Float -> Float -> IO ()
clearGameScreen Float
r Float
g Float
b
setCurrentMapIndex :: Int -> IOGame t s u v ()
setCurrentMapIndex :: forall t s u v. Int -> IOGame t s u v ()
setCurrentMapIndex Int
i = do
GameMap v
m <- forall t s u v. IOGame t s u v (GameMap v)
getRealMap
if forall t. GameMap t -> Bool
isMultiMap GameMap v
m
then forall v t s u. GameMap v -> IOGame t s u v ()
setRealMap (forall t. GameMap t -> Int -> GameMap t
updateCurrentIndex GameMap v
m Int
i)
else forall a. HasCallStack => String -> a
error String
"Game.setCurrentMapIndex error: you are not working with MultiMaps!"
enableGameFlags :: IOGame t s u v ()
enableGameFlags :: forall t s u v. IOGame t s u v ()
enableGameFlags = forall t s u v. GameFlags -> IOGame t s u v ()
setGameFlags (Bool
True,Bool
True,Bool
True)
disableGameFlags :: IOGame t s u v ()
disableGameFlags :: forall t s u v. IOGame t s u v ()
disableGameFlags = forall t s u v. GameFlags -> IOGame t s u v ()
setGameFlags (Bool
False,Bool
False,Bool
False)
enableMapDrawing :: IOGame t s u v ()
enableMapDrawing :: forall t s u v. IOGame t s u v ()
enableMapDrawing = do
(Bool
_,Bool
od,Bool
om) <- forall t s u v. IOGame t s u v GameFlags
getGameFlags
forall t s u v. GameFlags -> IOGame t s u v ()
setGameFlags (Bool
True,Bool
od,Bool
om)
disableMapDrawing :: IOGame t s u v ()
disableMapDrawing :: forall t s u v. IOGame t s u v ()
disableMapDrawing = do
(Bool
_,Bool
od,Bool
om) <- forall t s u v. IOGame t s u v GameFlags
getGameFlags
forall t s u v. GameFlags -> IOGame t s u v ()
setGameFlags (Bool
False,Bool
od,Bool
om)
enableObjectsDrawing :: IOGame t s u v ()
enableObjectsDrawing :: forall t s u v. IOGame t s u v ()
enableObjectsDrawing = do
(Bool
md,Bool
_,Bool
om) <- forall t s u v. IOGame t s u v GameFlags
getGameFlags
forall t s u v. GameFlags -> IOGame t s u v ()
setGameFlags (Bool
md,Bool
True,Bool
om)
disableObjectsDrawing :: IOGame t s u v ()
disableObjectsDrawing :: forall t s u v. IOGame t s u v ()
disableObjectsDrawing = do
(Bool
md,Bool
_,Bool
om) <- forall t s u v. IOGame t s u v GameFlags
getGameFlags
forall t s u v. GameFlags -> IOGame t s u v ()
setGameFlags (Bool
md,Bool
False,Bool
om)
enableObjectsMoving :: IOGame t s u v ()
enableObjectsMoving :: forall t s u v. IOGame t s u v ()
enableObjectsMoving = do
(Bool
md,Bool
od,Bool
_) <- forall t s u v. IOGame t s u v GameFlags
getGameFlags
forall t s u v. GameFlags -> IOGame t s u v ()
setGameFlags (Bool
md,Bool
od,Bool
True)
disableObjectsMoving :: IOGame t s u v ()
disableObjectsMoving :: forall t s u v. IOGame t s u v ()
disableObjectsMoving = do
(Bool
md,Bool
od,Bool
_) <- forall t s u v. IOGame t s u v GameFlags
getGameFlags
forall t s u v. GameFlags -> IOGame t s u v ()
setGameFlags (Bool
md,Bool
od,Bool
False)
drawAllObjects :: IOGame t s u v ()
drawAllObjects :: forall t s u v. IOGame t s u v ()
drawAllObjects = do
[ObjectManager s]
o <- forall t s u v. IOGame t s u v [ObjectManager s]
getObjectManagers
QuadricPrimitive
q <- forall t s u v. IOGame t s u v QuadricPrimitive
getQuadric
[TextureObject]
p <- forall t s u v. IOGame t s u v [TextureObject]
getPictureList
forall a t s u v. IO a -> IOGame t s u v a
liftIOtoIOGame forall a b. (a -> b) -> a -> b
$ forall t.
[ObjectManager t] -> QuadricPrimitive -> [TextureObject] -> IO ()
drawGameObjects [ObjectManager s]
o QuadricPrimitive
q [TextureObject]
p
drawObject :: GameObject s -> IOGame t s u v ()
drawObject :: forall s t u v. GameObject s -> IOGame t s u v ()
drawObject GameObject s
o = do
QuadricPrimitive
q <- forall t s u v. IOGame t s u v QuadricPrimitive
getQuadric
[TextureObject]
p <- forall t s u v. IOGame t s u v [TextureObject]
getPictureList
forall a t s u v. IO a -> IOGame t s u v a
liftIOtoIOGame forall a b. (a -> b) -> a -> b
$ forall t.
GameObject t -> QuadricPrimitive -> [TextureObject] -> IO ()
drawGameObject GameObject s
o QuadricPrimitive
q [TextureObject]
p
moveAllObjects :: IOGame t s u v ()
moveAllObjects :: forall t s u v. IOGame t s u v ()
moveAllObjects = do
[ObjectManager s]
m <- forall t s u v. IOGame t s u v [ObjectManager s]
getObjectManagers
let newManagers :: [ObjectManager s]
newManagers = forall t. [ObjectManager t] -> [ObjectManager t]
moveGameObjects [ObjectManager s]
m
forall s t u v. [ObjectManager s] -> IOGame t s u v ()
setObjectManagers [ObjectManager s]
newManagers
destroyObjects :: [GameObject s] -> IOGame t s u v ()
destroyObjects :: forall s t u v. [GameObject s] -> IOGame t s u v ()
destroyObjects = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
(>>) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s t u v. GameObject s -> IOGame t s u v ()
destroyObject) (forall (m :: * -> *) a. Monad m => a -> m a
return ())
destroyObject :: GameObject s -> IOGame t s u v ()
destroyObject :: forall s t u v. GameObject s -> IOGame t s u v ()
destroyObject GameObject s
obj = do
[ObjectManager s]
m <- forall t s u v. IOGame t s u v [ObjectManager s]
getObjectManagers
let objName :: String
objName = forall t. GameObject t -> String
getGameObjectName GameObject s
obj
String
mngName <- forall s t u v. GameObject s -> IOGame t s u v String
getObjectGroupName GameObject s
obj
let newManagers :: [ObjectManager s]
newManagers = forall t.
String -> String -> [ObjectManager t] -> [ObjectManager t]
destroyGameObject String
objName String
mngName [ObjectManager s]
m
forall s t u v. [ObjectManager s] -> IOGame t s u v ()
setObjectManagers [ObjectManager s]
newManagers
getObjectsFromGroup :: String -> IOGame t s u v [GameObject s]
getObjectsFromGroup :: forall t s u v. String -> IOGame t s u v [GameObject s]
getObjectsFromGroup String
mngName = do
ObjectManager s
mng <- forall t s u v. String -> IOGame t s u v (ObjectManager s)
findObjectManager String
mngName
forall (m :: * -> *) a. Monad m => a -> m a
return (forall t. ObjectManager t -> [GameObject t]
getObjectManagerObjects ObjectManager s
mng)
addObjectsToGroup :: [GameObject s] -> String -> IOGame t s u v ()
addObjectsToGroup :: forall s t u v. [GameObject s] -> String -> IOGame t s u v ()
addObjectsToGroup [GameObject s]
objs String
managerName = do
[ObjectManager s]
managers <- forall t s u v. IOGame t s u v [ObjectManager s]
getObjectManagers
let newManagers :: [ObjectManager s]
newManagers = forall t.
[GameObject t] -> String -> [ObjectManager t] -> [ObjectManager t]
addObjectsToManager [GameObject s]
objs String
managerName [ObjectManager s]
managers
forall s t u v. [ObjectManager s] -> IOGame t s u v ()
setObjectManagers [ObjectManager s]
newManagers
addObjectsToNewGroup :: [GameObject s] -> String -> IOGame t s u v ()
addObjectsToNewGroup :: forall s t u v. [GameObject s] -> String -> IOGame t s u v ()
addObjectsToNewGroup [GameObject s]
objs String
newMngName = do
let newManager :: ObjectManager s
newManager = forall t. String -> [GameObject t] -> ObjectManager t
objectGroup String
newMngName [GameObject s]
objs
[ObjectManager s]
managers <- forall t s u v. IOGame t s u v [ObjectManager s]
getObjectManagers
forall s t u v. [ObjectManager s] -> IOGame t s u v ()
setObjectManagers (ObjectManager s
newManagerforall a. a -> [a] -> [a]
:[ObjectManager s]
managers)
findObjectManager :: String -> IOGame t s u v (ObjectManager s)
findObjectManager :: forall t s u v. String -> IOGame t s u v (ObjectManager s)
findObjectManager String
mngName = forall t. String -> [ObjectManager t] -> ObjectManager t
searchObjectManager String
mngName forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall t s u v. IOGame t s u v [ObjectManager s]
getObjectManagers
findObject :: String -> String -> IOGame t s u v (GameObject s)
findObject :: forall t s u v. String -> String -> IOGame t s u v (GameObject s)
findObject String
objName String
mngName = do
[ObjectManager s]
objectManagers <- forall t s u v. IOGame t s u v [ObjectManager s]
getObjectManagers
let m :: ObjectManager s
m = forall t. String -> [ObjectManager t] -> ObjectManager t
searchObjectManager String
mngName [ObjectManager s]
objectManagers
forall (m :: * -> *) a. Monad m => a -> m a
return (forall t. String -> ObjectManager t -> GameObject t
searchGameObject String
objName ObjectManager s
m)
getObjectName :: GameObject s -> IOGame t s u v String
getObjectName :: forall s t u v. GameObject s -> IOGame t s u v String
getObjectName GameObject s
o = forall (m :: * -> *) a. Monad m => a -> m a
return (forall t. GameObject t -> String
getGameObjectName GameObject s
o)
getObjectGroupName :: GameObject s -> IOGame t s u v String
getObjectGroupName :: forall s t u v. GameObject s -> IOGame t s u v String
getObjectGroupName GameObject s
o = do [ObjectManager s]
managers <- forall t s u v. IOGame t s u v [ObjectManager s]
getObjectManagers
let obj :: GameObject s
obj = forall t. GameObject t -> [ObjectManager t] -> GameObject t
findObjectFromId GameObject s
o [ObjectManager s]
managers
forall (m :: * -> *) a. Monad m => a -> m a
return (forall t. GameObject t -> String
getGameObjectManagerName GameObject s
obj)
getObjectAsleep :: GameObject s -> IOGame t s u v Bool
getObjectAsleep :: forall s t u v. GameObject s -> IOGame t s u v Bool
getObjectAsleep GameObject s
o = do [ObjectManager s]
managers <- forall t s u v. IOGame t s u v [ObjectManager s]
getObjectManagers
let obj :: GameObject s
obj = forall t. GameObject t -> [ObjectManager t] -> GameObject t
findObjectFromId GameObject s
o [ObjectManager s]
managers
forall (m :: * -> *) a. Monad m => a -> m a
return (forall t. GameObject t -> Bool
getGameObjectAsleep GameObject s
obj)
getObjectSize :: GameObject s -> IOGame t s u v (GLdouble,GLdouble)
getObjectSize :: forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSize GameObject s
o = do [ObjectManager s]
managers <- forall t s u v. IOGame t s u v [ObjectManager s]
getObjectManagers
let obj :: GameObject s
obj = forall t. GameObject t -> [ObjectManager t] -> GameObject t
findObjectFromId GameObject s
o [ObjectManager s]
managers
forall (m :: * -> *) a. Monad m => a -> m a
return (forall t. GameObject t -> Point2D
getGameObjectSize GameObject s
obj)
getObjectPosition :: GameObject s -> IOGame t s u v (GLdouble,GLdouble)
getObjectPosition :: forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectPosition GameObject s
o = do [ObjectManager s]
managers <- forall t s u v. IOGame t s u v [ObjectManager s]
getObjectManagers
let obj :: GameObject s
obj = forall t. GameObject t -> [ObjectManager t] -> GameObject t
findObjectFromId GameObject s
o [ObjectManager s]
managers
forall (m :: * -> *) a. Monad m => a -> m a
return (forall t. GameObject t -> Point2D
getGameObjectPosition GameObject s
obj)
getObjectSpeed :: GameObject s -> IOGame t s u v (GLdouble,GLdouble)
getObjectSpeed :: forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSpeed GameObject s
o = do [ObjectManager s]
managers <- forall t s u v. IOGame t s u v [ObjectManager s]
getObjectManagers
let obj :: GameObject s
obj = forall t. GameObject t -> [ObjectManager t] -> GameObject t
findObjectFromId GameObject s
o [ObjectManager s]
managers
forall (m :: * -> *) a. Monad m => a -> m a
return (forall t. GameObject t -> Point2D
getGameObjectSpeed GameObject s
obj)
getObjectAttribute :: GameObject s -> IOGame t s u v s
getObjectAttribute :: forall s t u v. GameObject s -> IOGame t s u v s
getObjectAttribute GameObject s
o = do [ObjectManager s]
managers <- forall t s u v. IOGame t s u v [ObjectManager s]
getObjectManagers
let obj :: GameObject s
obj = forall t. GameObject t -> [ObjectManager t] -> GameObject t
findObjectFromId GameObject s
o [ObjectManager s]
managers
forall (m :: * -> *) a. Monad m => a -> m a
return (forall t. GameObject t -> t
getGameObjectAttribute GameObject s
obj)
setObjectAsleep :: Bool -> GameObject s -> IOGame t s u v ()
setObjectAsleep :: forall s t u v. Bool -> GameObject s -> IOGame t s u v ()
setObjectAsleep Bool
asleep GameObject s
obj = forall s t u v.
GameObject s -> (GameObject s -> GameObject s) -> IOGame t s u v ()
replaceObject GameObject s
obj (forall t. Bool -> GameObject t -> GameObject t
updateObjectAsleep Bool
asleep)
setObjectPosition :: (GLdouble,GLdouble) -> GameObject s -> IOGame t s u v ()
setObjectPosition :: forall s t u v. Point2D -> GameObject s -> IOGame t s u v ()
setObjectPosition Point2D
pos GameObject s
obj = forall s t u v.
GameObject s -> (GameObject s -> GameObject s) -> IOGame t s u v ()
replaceObject GameObject s
obj (forall t. Point2D -> GameObject t -> GameObject t
updateObjectPosition Point2D
pos)
setObjectSpeed :: (GLdouble,GLdouble) -> GameObject s -> IOGame t s u v ()
setObjectSpeed :: forall s t u v. Point2D -> GameObject s -> IOGame t s u v ()
setObjectSpeed Point2D
speed GameObject s
obj = forall s t u v.
GameObject s -> (GameObject s -> GameObject s) -> IOGame t s u v ()
replaceObject GameObject s
obj (forall t. Point2D -> GameObject t -> GameObject t
updateObjectSpeed Point2D
speed)
setObjectCurrentPicture :: Int -> GameObject s -> IOGame t s u v ()
setObjectCurrentPicture :: forall s t u v. Int -> GameObject s -> IOGame t s u v ()
setObjectCurrentPicture Int
n GameObject s
obj = do
[TextureObject]
picList <- forall t s u v. IOGame t s u v [TextureObject]
getPictureList
forall s t u v.
GameObject s -> (GameObject s -> GameObject s) -> IOGame t s u v ()
replaceObject GameObject s
obj (forall t. Int -> Int -> GameObject t -> GameObject t
updateObjectPicture Int
n (forall (t :: * -> *) a. Foldable t => t a -> Int
length [TextureObject]
picList forall a. Num a => a -> a -> a
- Int
1))
setObjectAttribute :: s -> GameObject s -> IOGame t s u v ()
setObjectAttribute :: forall s t u v. s -> GameObject s -> IOGame t s u v ()
setObjectAttribute s
a GameObject s
obj = forall s t u v.
GameObject s -> (GameObject s -> GameObject s) -> IOGame t s u v ()
replaceObject GameObject s
obj (forall t. t -> GameObject t -> GameObject t
updateObjectAttribute s
a)
replaceObject :: GameObject s -> (GameObject s -> GameObject s) -> IOGame t s u v ()
replaceObject :: forall s t u v.
GameObject s -> (GameObject s -> GameObject s) -> IOGame t s u v ()
replaceObject GameObject s
obj GameObject s -> GameObject s
f = do
String
managerName <- forall s t u v. GameObject s -> IOGame t s u v String
getObjectGroupName GameObject s
obj
[ObjectManager s]
oldManagers <- forall t s u v. IOGame t s u v [ObjectManager s]
getObjectManagers
let objectId :: Integer
objectId = forall t. GameObject t -> Integer
getGameObjectId GameObject s
obj
newManagers :: [ObjectManager s]
newManagers = forall t.
(GameObject t -> GameObject t)
-> Integer -> String -> [ObjectManager t] -> [ObjectManager t]
updateObject GameObject s -> GameObject s
f Integer
objectId String
managerName [ObjectManager s]
oldManagers
forall s t u v. [ObjectManager s] -> IOGame t s u v ()
setObjectManagers [ObjectManager s]
newManagers
reverseXSpeed :: GameObject s -> IOGame t s u v ()
reverseXSpeed :: forall s t u v. GameObject s -> IOGame t s u v ()
reverseXSpeed GameObject s
o = do (Radius
vX,Radius
vY) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSpeed GameObject s
o
forall s t u v. Point2D -> GameObject s -> IOGame t s u v ()
setObjectSpeed (-Radius
vX,Radius
vY) GameObject s
o
reverseYSpeed :: GameObject s -> IOGame t s u v ()
reverseYSpeed :: forall s t u v. GameObject s -> IOGame t s u v ()
reverseYSpeed GameObject s
o = do (Radius
vX,Radius
vY) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSpeed GameObject s
o
forall s t u v. Point2D -> GameObject s -> IOGame t s u v ()
setObjectSpeed (Radius
vX,-Radius
vY) GameObject s
o
objectTopMapCollision :: GameObject s -> IOGame t s u v Bool
objectTopMapCollision :: forall s t u v. GameObject s -> IOGame t s u v Bool
objectTopMapCollision GameObject s
o = do
Bool
asleep <- forall s t u v. GameObject s -> IOGame t s u v Bool
getObjectAsleep GameObject s
o
if Bool
asleep
then forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
else do GameMap v
m <- forall t s u v. IOGame t s u v (GameMap v)
getMap
(Radius
_,Radius
pY) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectPosition GameObject s
o
(Radius
_,Radius
sY) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSize GameObject s
o
let (Radius
_,Radius
mY) = forall t. GameMap t -> Point2D
getMapSize GameMap v
m
forall (m :: * -> *) a. Monad m => a -> m a
return (Radius
pY forall a. Num a => a -> a -> a
+ Radius
sYforall a. Fractional a => a -> a -> a
/Radius
2 forall a. Ord a => a -> a -> Bool
> forall a b. (Real a, Fractional b) => a -> b
realToFrac Radius
mY)
objectTopMapFutureCollision :: GameObject s -> IOGame t s u v Bool
objectTopMapFutureCollision :: forall s t u v. GameObject s -> IOGame t s u v Bool
objectTopMapFutureCollision GameObject s
o = do
Bool
asleep <- forall s t u v. GameObject s -> IOGame t s u v Bool
getObjectAsleep GameObject s
o
if Bool
asleep
then forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
else do GameMap v
m <- forall t s u v. IOGame t s u v (GameMap v)
getMap
(Radius
_,Radius
pY) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectPosition GameObject s
o
(Radius
_,Radius
vY) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSpeed GameObject s
o
(Radius
_,Radius
sY) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSize GameObject s
o
let (Radius
_,Radius
mY) = forall t. GameMap t -> Point2D
getMapSize GameMap v
m
forall (m :: * -> *) a. Monad m => a -> m a
return (Radius
pY forall a. Num a => a -> a -> a
+ Radius
sYforall a. Fractional a => a -> a -> a
/Radius
2 forall a. Num a => a -> a -> a
+ Radius
vY forall a. Ord a => a -> a -> Bool
> forall a b. (Real a, Fractional b) => a -> b
realToFrac Radius
mY)
objectBottomMapCollision :: GameObject s -> IOGame t s u v Bool
objectBottomMapCollision :: forall s t u v. GameObject s -> IOGame t s u v Bool
objectBottomMapCollision GameObject s
o = do
Bool
asleep <- forall s t u v. GameObject s -> IOGame t s u v Bool
getObjectAsleep GameObject s
o
if Bool
asleep
then forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
else do (Radius
_,Radius
pY) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectPosition GameObject s
o
(Radius
_,Radius
sY) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSize GameObject s
o
forall (m :: * -> *) a. Monad m => a -> m a
return (Radius
pY forall a. Num a => a -> a -> a
- Radius
sYforall a. Fractional a => a -> a -> a
/Radius
2 forall a. Ord a => a -> a -> Bool
< Radius
0)
objectBottomMapFutureCollision :: GameObject s -> IOGame t s u v Bool
objectBottomMapFutureCollision :: forall s t u v. GameObject s -> IOGame t s u v Bool
objectBottomMapFutureCollision GameObject s
o = do
Bool
asleep <- forall s t u v. GameObject s -> IOGame t s u v Bool
getObjectAsleep GameObject s
o
if Bool
asleep
then forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
else do (Radius
_,Radius
pY) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectPosition GameObject s
o
(Radius
_,Radius
sY) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSize GameObject s
o
(Radius
_,Radius
vY) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSpeed GameObject s
o
forall (m :: * -> *) a. Monad m => a -> m a
return (Radius
pY forall a. Num a => a -> a -> a
- Radius
sYforall a. Fractional a => a -> a -> a
/Radius
2 forall a. Num a => a -> a -> a
+ Radius
vY forall a. Ord a => a -> a -> Bool
< Radius
0)
objectRightMapCollision :: GameObject s -> IOGame t s u v Bool
objectRightMapCollision :: forall s t u v. GameObject s -> IOGame t s u v Bool
objectRightMapCollision GameObject s
o = do
Bool
asleep <- forall s t u v. GameObject s -> IOGame t s u v Bool
getObjectAsleep GameObject s
o
if Bool
asleep
then forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
else do GameMap v
m <- forall t s u v. IOGame t s u v (GameMap v)
getMap
(Radius
pX,Radius
_) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectPosition GameObject s
o
(Radius
sX,Radius
_) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSize GameObject s
o
let (Radius
mX,Radius
_) = forall t. GameMap t -> Point2D
getMapSize GameMap v
m
forall (m :: * -> *) a. Monad m => a -> m a
return (Radius
pX forall a. Num a => a -> a -> a
+ Radius
sXforall a. Fractional a => a -> a -> a
/Radius
2 forall a. Ord a => a -> a -> Bool
> forall a b. (Real a, Fractional b) => a -> b
realToFrac Radius
mX)
objectRightMapFutureCollision :: GameObject s -> IOGame t s u v Bool
objectRightMapFutureCollision :: forall s t u v. GameObject s -> IOGame t s u v Bool
objectRightMapFutureCollision GameObject s
o = do
Bool
asleep <- forall s t u v. GameObject s -> IOGame t s u v Bool
getObjectAsleep GameObject s
o
if Bool
asleep
then forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
else do GameMap v
m <- forall t s u v. IOGame t s u v (GameMap v)
getMap
(Radius
pX,Radius
_) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectPosition GameObject s
o
(Radius
sX,Radius
_) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSize GameObject s
o
(Radius
vX,Radius
_) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSpeed GameObject s
o
let (Radius
mX,Radius
_) = forall t. GameMap t -> Point2D
getMapSize GameMap v
m
forall (m :: * -> *) a. Monad m => a -> m a
return (Radius
pX forall a. Num a => a -> a -> a
+ Radius
sXforall a. Fractional a => a -> a -> a
/Radius
2 forall a. Num a => a -> a -> a
+ Radius
vX forall a. Ord a => a -> a -> Bool
> forall a b. (Real a, Fractional b) => a -> b
realToFrac Radius
mX)
objectLeftMapCollision :: GameObject s -> IOGame t s u v Bool
objectLeftMapCollision :: forall s t u v. GameObject s -> IOGame t s u v Bool
objectLeftMapCollision GameObject s
o = do
Bool
asleep <- forall s t u v. GameObject s -> IOGame t s u v Bool
getObjectAsleep GameObject s
o
if Bool
asleep
then forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
else do (Radius
pX,Radius
_) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectPosition GameObject s
o
(Radius
sX,Radius
_) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSize GameObject s
o
forall (m :: * -> *) a. Monad m => a -> m a
return (Radius
pX forall a. Num a => a -> a -> a
- Radius
sXforall a. Fractional a => a -> a -> a
/Radius
2 forall a. Ord a => a -> a -> Bool
< Radius
0)
objectLeftMapFutureCollision :: GameObject s -> IOGame t s u v Bool
objectLeftMapFutureCollision :: forall s t u v. GameObject s -> IOGame t s u v Bool
objectLeftMapFutureCollision GameObject s
o = do
Bool
asleep <- forall s t u v. GameObject s -> IOGame t s u v Bool
getObjectAsleep GameObject s
o
if Bool
asleep
then forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
else do (Radius
pX,Radius
_) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectPosition GameObject s
o
(Radius
sX,Radius
_) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSize GameObject s
o
(Radius
vX,Radius
_) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSpeed GameObject s
o
forall (m :: * -> *) a. Monad m => a -> m a
return (Radius
pX forall a. Num a => a -> a -> a
- Radius
sXforall a. Fractional a => a -> a -> a
/Radius
2 forall a. Num a => a -> a -> a
+ Radius
vX forall a. Ord a => a -> a -> Bool
< Radius
0)
objectsCollision :: GameObject s -> GameObject s -> IOGame t s u v Bool
objectsCollision :: forall s t u v. GameObject s -> GameObject s -> IOGame t s u v Bool
objectsCollision GameObject s
o1 GameObject s
o2 = do
Bool
asleep1 <- forall s t u v. GameObject s -> IOGame t s u v Bool
getObjectAsleep GameObject s
o1
Bool
asleep2 <- forall s t u v. GameObject s -> IOGame t s u v Bool
getObjectAsleep GameObject s
o2
if Bool
asleep1 Bool -> Bool -> Bool
|| Bool
asleep2
then forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
else do (Radius
p1X,Radius
p1Y) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectPosition GameObject s
o1
(Radius
p2X,Radius
p2Y) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectPosition GameObject s
o2
(Radius
s1X,Radius
s1Y) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSize GameObject s
o1
(Radius
s2X,Radius
s2Y) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSize GameObject s
o2
let aX1 :: Radius
aX1 = Radius
p1X forall a. Num a => a -> a -> a
- Radius
s1Xforall a. Fractional a => a -> a -> a
/Radius
2
aX2 :: Radius
aX2 = Radius
p1X forall a. Num a => a -> a -> a
+ Radius
s1Xforall a. Fractional a => a -> a -> a
/Radius
2
aY1 :: Radius
aY1 = Radius
p1Y forall a. Num a => a -> a -> a
- Radius
s1Yforall a. Fractional a => a -> a -> a
/Radius
2
aY2 :: Radius
aY2 = Radius
p1Y forall a. Num a => a -> a -> a
+ Radius
s1Yforall a. Fractional a => a -> a -> a
/Radius
2
bX1 :: Radius
bX1 = Radius
p2X forall a. Num a => a -> a -> a
- Radius
s2Xforall a. Fractional a => a -> a -> a
/Radius
2
bX2 :: Radius
bX2 = Radius
p2X forall a. Num a => a -> a -> a
+ Radius
s2Xforall a. Fractional a => a -> a -> a
/Radius
2
bY1 :: Radius
bY1 = Radius
p2Y forall a. Num a => a -> a -> a
- Radius
s2Yforall a. Fractional a => a -> a -> a
/Radius
2
bY2 :: Radius
bY2 = Radius
p2Y forall a. Num a => a -> a -> a
+ Radius
s2Yforall a. Fractional a => a -> a -> a
/Radius
2
forall (m :: * -> *) a. Monad m => a -> m a
return (Radius
bX1 forall a. Ord a => a -> a -> Bool
< Radius
aX2 Bool -> Bool -> Bool
&& Radius
aX1 forall a. Ord a => a -> a -> Bool
< Radius
bX2 Bool -> Bool -> Bool
&& Radius
bY1 forall a. Ord a => a -> a -> Bool
< Radius
aY2 Bool -> Bool -> Bool
&& Radius
aY1 forall a. Ord a => a -> a -> Bool
< Radius
bY2)
objectsFutureCollision :: GameObject s -> GameObject s -> IOGame t s u v Bool
objectsFutureCollision :: forall s t u v. GameObject s -> GameObject s -> IOGame t s u v Bool
objectsFutureCollision GameObject s
o1 GameObject s
o2 = do
Bool
asleep1 <- forall s t u v. GameObject s -> IOGame t s u v Bool
getObjectAsleep GameObject s
o1
Bool
asleep2 <- forall s t u v. GameObject s -> IOGame t s u v Bool
getObjectAsleep GameObject s
o2
if Bool
asleep1 Bool -> Bool -> Bool
|| Bool
asleep2
then forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
else do (Radius
p1X,Radius
p1Y) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectPosition GameObject s
o1
(Radius
p2X,Radius
p2Y) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectPosition GameObject s
o2
(Radius
v1X,Radius
v1Y) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSpeed GameObject s
o1
(Radius
v2X,Radius
v2Y) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSpeed GameObject s
o2
(Radius
s1X,Radius
s1Y) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSize GameObject s
o1
(Radius
s2X,Radius
s2Y) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSize GameObject s
o2
let aX1 :: Radius
aX1 = Radius
p1X forall a. Num a => a -> a -> a
- Radius
s1Xforall a. Fractional a => a -> a -> a
/Radius
2 forall a. Num a => a -> a -> a
+ Radius
v1X
aX2 :: Radius
aX2 = Radius
p1X forall a. Num a => a -> a -> a
+ Radius
s1Xforall a. Fractional a => a -> a -> a
/Radius
2 forall a. Num a => a -> a -> a
+ Radius
v1X
aY1 :: Radius
aY1 = Radius
p1Y forall a. Num a => a -> a -> a
- Radius
s1Yforall a. Fractional a => a -> a -> a
/Radius
2 forall a. Num a => a -> a -> a
+ Radius
v1Y
aY2 :: Radius
aY2 = Radius
p1Y forall a. Num a => a -> a -> a
+ Radius
s1Yforall a. Fractional a => a -> a -> a
/Radius
2 forall a. Num a => a -> a -> a
+ Radius
v1Y
bX1 :: Radius
bX1 = Radius
p2X forall a. Num a => a -> a -> a
- Radius
s2Xforall a. Fractional a => a -> a -> a
/Radius
2 forall a. Num a => a -> a -> a
+ Radius
v2X
bX2 :: Radius
bX2 = Radius
p2X forall a. Num a => a -> a -> a
+ Radius
s2Xforall a. Fractional a => a -> a -> a
/Radius
2 forall a. Num a => a -> a -> a
+ Radius
v2X
bY1 :: Radius
bY1 = Radius
p2Y forall a. Num a => a -> a -> a
- Radius
s2Yforall a. Fractional a => a -> a -> a
/Radius
2 forall a. Num a => a -> a -> a
+ Radius
v2Y
bY2 :: Radius
bY2 = Radius
p2Y forall a. Num a => a -> a -> a
+ Radius
s2Yforall a. Fractional a => a -> a -> a
/Radius
2 forall a. Num a => a -> a -> a
+ Radius
v2Y
forall (m :: * -> *) a. Monad m => a -> m a
return (Radius
bX1 forall a. Ord a => a -> a -> Bool
< Radius
aX2 Bool -> Bool -> Bool
&& Radius
aX1 forall a. Ord a => a -> a -> Bool
< Radius
bX2 Bool -> Bool -> Bool
&& Radius
bY1 forall a. Ord a => a -> a -> Bool
< Radius
aY2 Bool -> Bool -> Bool
&& Radius
aY1 forall a. Ord a => a -> a -> Bool
< Radius
bY2)
objectListObjectCollision :: [GameObject s] -> GameObject s -> IOGame t s u v Bool
objectListObjectCollision :: forall s t u v.
[GameObject s] -> GameObject s -> IOGame t s u v Bool
objectListObjectCollision [] GameObject s
_ = forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
objectListObjectCollision (GameObject s
a:[GameObject s]
as) GameObject s
b = do
Bool
col <- forall s t u v. GameObject s -> GameObject s -> IOGame t s u v Bool
objectsCollision GameObject s
a GameObject s
b
if Bool
col
then forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
else forall s t u v.
[GameObject s] -> GameObject s -> IOGame t s u v Bool
objectListObjectCollision [GameObject s]
as GameObject s
b
objectListObjectFutureCollision :: [GameObject s] -> GameObject s -> IOGame t s u v Bool
objectListObjectFutureCollision :: forall s t u v.
[GameObject s] -> GameObject s -> IOGame t s u v Bool
objectListObjectFutureCollision [] GameObject s
_ = forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
objectListObjectFutureCollision (GameObject s
a:[GameObject s]
as) GameObject s
b = do
Bool
col <- forall s t u v. GameObject s -> GameObject s -> IOGame t s u v Bool
objectsFutureCollision GameObject s
a GameObject s
b
if Bool
col
then forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
else forall s t u v.
[GameObject s] -> GameObject s -> IOGame t s u v Bool
objectListObjectFutureCollision [GameObject s]
as GameObject s
b
pointsObjectCollision :: GLdouble -> GLdouble -> GLdouble -> GLdouble -> GameObject s -> IOGame t s u v Bool
pointsObjectCollision :: forall s t u v.
Radius
-> Radius
-> Radius
-> Radius
-> GameObject s
-> IOGame t s u v Bool
pointsObjectCollision Radius
p1X Radius
p1Y Radius
s1X Radius
s1Y GameObject s
o2 = do
Bool
asleep <- forall s t u v. GameObject s -> IOGame t s u v Bool
getObjectAsleep GameObject s
o2
if Bool
asleep
then forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
else do (Radius
p2X,Radius
p2Y) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectPosition GameObject s
o2
(Radius
s2X,Radius
s2Y) <- forall s t u v. GameObject s -> IOGame t s u v Point2D
getObjectSize GameObject s
o2
let aX1 :: Radius
aX1 = Radius
p1X forall a. Num a => a -> a -> a
- Radius
s1Xforall a. Fractional a => a -> a -> a
/Radius
2
aX2 :: Radius
aX2 = Radius
p1X forall a. Num a => a -> a -> a
+ Radius
s1Xforall a. Fractional a => a -> a -> a
/Radius
2
aY1 :: Radius
aY1 = Radius
p1Y forall a. Num a => a -> a -> a
- Radius
s1Yforall a. Fractional a => a -> a -> a
/Radius
2
aY2 :: Radius
aY2 = Radius
p1Y forall a. Num a => a -> a -> a
+ Radius
s1Yforall a. Fractional a => a -> a -> a
/Radius
2
bX1 :: Radius
bX1 = Radius
p2X forall a. Num a => a -> a -> a
- Radius
s2Xforall a. Fractional a => a -> a -> a
/Radius
2
bX2 :: Radius
bX2 = Radius
p2X forall a. Num a => a -> a -> a
+ Radius
s2Xforall a. Fractional a => a -> a -> a
/Radius
2
bY1 :: Radius
bY1 = Radius
p2Y forall a. Num a => a -> a -> a
- Radius
s2Yforall a. Fractional a => a -> a -> a
/Radius
2
bY2 :: Radius
bY2 = Radius
p2Y forall a. Num a => a -> a -> a
+ Radius
s2Yforall a. Fractional a => a -> a -> a
/Radius
2
forall (m :: * -> *) a. Monad m => a -> m a
return (Radius
bX1 forall a. Ord a => a -> a -> Bool
< Radius
aX2 Bool -> Bool -> Bool
&& Radius
aX1 forall a. Ord a => a -> a -> Bool
< Radius
bX2 Bool -> Bool -> Bool
&& Radius
bY1 forall a. Ord a => a -> a -> Bool
< Radius
aY2 Bool -> Bool -> Bool
&& Radius
aY1 forall a. Ord a => a -> a -> Bool
< Radius
bY2)
pointsObjectListCollision :: GLdouble -> GLdouble -> GLdouble -> GLdouble -> [GameObject s] -> IOGame t s u v Bool
pointsObjectListCollision :: forall s t u v.
Radius
-> Radius
-> Radius
-> Radius
-> [GameObject s]
-> IOGame t s u v Bool
pointsObjectListCollision Radius
_ Radius
_ Radius
_ Radius
_ [] = forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
pointsObjectListCollision Radius
p1X Radius
p1Y Radius
s1X Radius
s1Y (GameObject s
o:[GameObject s]
os) = do
Bool
col <- forall s t u v.
Radius
-> Radius
-> Radius
-> Radius
-> GameObject s
-> IOGame t s u v Bool
pointsObjectCollision Radius
p1X Radius
p1Y Radius
s1X Radius
s1Y GameObject s
o
if Bool
col
then forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
else forall s t u v.
Radius
-> Radius
-> Radius
-> Radius
-> [GameObject s]
-> IOGame t s u v Bool
pointsObjectListCollision Radius
p1X Radius
p1Y Radius
s1X Radius
s1Y [GameObject s]
os
printOnPrompt :: Show a => a -> IOGame t s u v ()
printOnPrompt :: forall a t s u v. Show a => a -> IOGame t s u v ()
printOnPrompt = forall a t s u v. (a -> IO ()) -> a -> IOGame t s u v ()
liftIOtoIOGame' forall a. Show a => a -> IO ()
print
printOnScreen :: String -> BitmapFont -> (GLdouble,GLdouble) -> GLclampf -> GLclampf -> GLclampf -> IOGame t s u v ()
printOnScreen :: forall t s u v.
String
-> BitmapFont
-> Point2D
-> Float
-> Float
-> Float
-> IOGame t s u v ()
printOnScreen String
text BitmapFont
font Point2D
pos Float
r Float
g Float
b = do
[Text]
t <- forall t s u v. IOGame t s u v [Text]
getTextList
forall t s u v. [Text] -> IOGame t s u v ()
setTextList ((String
text,BitmapFont
font,Point2D
pos,Float
r,Float
g,Float
b) forall a. a -> [a] -> [a]
: [Text]
t)
printText :: IOGame t s u v ()
printText :: forall t s u v. IOGame t s u v ()
printText = do
[Text]
t <- forall t s u v. IOGame t s u v [Text]
getTextList
forall a t s u v. IO a -> IOGame t s u v a
liftIOtoIOGame forall a b. (a -> b) -> a -> b
$ [Text] -> IO ()
putGameText [Text]
t
forall t s u v. [Text] -> IOGame t s u v ()
setTextList []
randomInt :: (Int,Int) -> IOGame t s u v Int
randomInt :: forall t s u v. (Int, Int) -> IOGame t s u v Int
randomInt (Int
x,Int
y) = forall a t s u v. IO a -> IOGame t s u v a
liftIOtoIOGame forall a b. (a -> b) -> a -> b
$ (Int, Int) -> IO Int
randInt (Int
x,Int
y)
randomFloat :: (Float,Float) -> IOGame t s u v Float
randomFloat :: forall t s u v. (Float, Float) -> IOGame t s u v Float
randomFloat (Float
x,Float
y) = forall a t s u v. IO a -> IOGame t s u v a
liftIOtoIOGame forall a b. (a -> b) -> a -> b
$ (Float, Float) -> IO Float
randFloat (Float
x,Float
y)
randomDouble :: (Double,Double) -> IOGame t s u v Double
randomDouble :: forall t s u v. Point2D -> IOGame t s u v Radius
randomDouble (Radius
x,Radius
y) = forall a t s u v. IO a -> IOGame t s u v a
liftIOtoIOGame forall a b. (a -> b) -> a -> b
$ Point2D -> IO Radius
randDouble (Radius
x,Radius
y)
showFPS :: BitmapFont -> (GLdouble,GLdouble) -> GLclampf -> GLclampf -> GLclampf -> IOGame t s u v ()
showFPS :: forall t s u v.
BitmapFont
-> Point2D -> Float -> Float -> Float -> IOGame t s u v ()
showFPS BitmapFont
font Point2D
pos Float
r Float
g Float
b = do
(Int
framei,Int
timebasei,Float
fps) <- forall t s u v. IOGame t s u v (Int, Int, Float)
getFpsInfo
Int
timei <- forall t s u v. IOGame t s u v Int
getElapsedTime
let frame :: Float
frame = forall a. Enum a => Int -> a
toEnum (Int
framei forall a. Num a => a -> a -> a
+ Int
1) :: Float
timebase :: Float
timebase = forall a. Enum a => Int -> a
toEnum Int
timebasei :: Float
time :: Float
time = forall a. Enum a => Int -> a
toEnum Int
timei :: Float
if Int
timei forall a. Num a => a -> a -> a
- Int
timebasei forall a. Ord a => a -> a -> Bool
> Int
1000
then forall t s u v. (Int, Int, Float) -> IOGame t s u v ()
setFpsInfo (Int
0,Int
timei,Float
frameforall a. Num a => a -> a -> a
*forall a. Enum a => Int -> a
toEnum Int
1000forall a. Fractional a => a -> a -> a
/(Float
timeforall a. Num a => a -> a -> a
-Float
timebase))
else forall t s u v. (Int, Int, Float) -> IOGame t s u v ()
setFpsInfo (Int
framei forall a. Num a => a -> a -> a
+ Int
1,Int
timebasei,Float
fps)
forall t s u v.
String
-> BitmapFont
-> Point2D
-> Float
-> Float
-> Float
-> IOGame t s u v ()
printOnScreen (forall r. PrintfType r => String -> r
printf String
"%.1f" Float
fps) BitmapFont
font Point2D
pos Float
r Float
g Float
b
getElapsedTime :: IOGame t s u v Int
getElapsedTime :: forall t s u v. IOGame t s u v Int
getElapsedTime = forall a t s u v. IO a -> IOGame t s u v a
liftIOtoIOGame forall a b. (a -> b) -> a -> b
$ forall t a (m :: * -> *). (HasGetter t a, MonadIO m) => t -> m a
get IO Int
elapsedTime
wait :: Int -> IOGame t s u v ()
wait :: forall t s u v. Int -> IOGame t s u v ()
wait Int
delay = do
forall t s u v. IOGame t s u v ()
printText
(Int
framei,Int
timebasei,Float
fps) <- forall t s u v. IOGame t s u v (Int, Int, Float)
getFpsInfo
forall t s u v. (Int, Int, Float) -> IOGame t s u v ()
setFpsInfo (Int
framei,Int
timebasei forall a. Num a => a -> a -> a
+ Int
delay,Float
fps)
Int
startTime <- forall t s u v. IOGame t s u v Int
getElapsedTime
forall t s u v. Int -> Int -> IOGame t s u v ()
waitAux Int
delay Int
startTime
waitAux :: Int -> Int -> IOGame t s u v ()
waitAux :: forall t s u v. Int -> Int -> IOGame t s u v ()
waitAux Int
delay Int
startTime = do
Int
presentTime <- forall t s u v. IOGame t s u v Int
getElapsedTime
if Int
presentTime forall a. Num a => a -> a -> a
- Int
startTime forall a. Ord a => a -> a -> Bool
> Int
delay
then forall (m :: * -> *) a. Monad m => a -> m a
return ()
else forall t s u v. Int -> Int -> IOGame t s u v ()
waitAux Int
delay Int
startTime