gloss-game 0.3.0.0 → 0.3.1.0
raw patch · 2 files changed
+18/−10 lines, 2 files
Files
- Graphics/Gloss/Game.hs +17/−9
- gloss-game.cabal +1/−1
Graphics/Gloss/Game.hs view
@@ -27,13 +27,14 @@ play, playInScene, -- * Game scenes- Animation, animation, noAnimation,+ Animation, animation, noAnimation, animationPicture, Scene, picture, picturing, animating, translating, rotating, scaling, scenes, drawScene, ) where -- standard libraries import Data.IORef+import Data.Maybe import System.IO.Unsafe (unsafePerformIO) -- packages@@ -188,6 +189,14 @@ noAnimation :: Animation noAnimation = animation [] 1 0 +animationPicture :: Float -> Animation -> Maybe Picture+animationPicture now (Animation pics delay start)+ | start > now = Nothing+ | i >= length pics = Nothing+ | otherwise = Just $ pics !! i+ where+ i = round ((now - start) / delay)+ -- |A scene describes the rendering of a world state — i.e., which picture should be draw depending on the current time -- and of the state of the world. --@@ -212,14 +221,7 @@ -- animating :: (world -> Animation) -> Picture -> Scene world animating anim defaultPic- = Picturing (\currentTime world -> pickPicture currentTime (anim world))- where- pickPicture now (Animation pics delay start)- | start > now = defaultPic- | i >= length pics = defaultPic- | otherwise = pics !! i- where- i = round ((now - start) / delay)+ = Picturing (\currentTime world -> fromMaybe defaultPic $ animationPicture currentTime (anim world)) -- |Move a scene in dependences on a world-dependent location. --@@ -251,3 +253,9 @@ drawS (Rotating rotation scene) = rotate (rotation world) (drawS scene) drawS (Scaling scaling scene) = let (xf, yf) = scaling world in scale xf yf (drawS scene) drawS (Scenes scenes) = pictures $ map drawS scenes+++-- -- Game objects+-- -- ------------+-- +-- data Object objClass =
gloss-game.cabal view
@@ -1,5 +1,5 @@ Name: gloss-game-Version: 0.3.0.0+Version: 0.3.1.0 Cabal-version: >= 1.6 Tested-with: GHC >= 7.6 Build-type: Simple