free-game 0.3.1.3 → 0.3.1.4
raw patch · 4 files changed
+33/−7 lines, 4 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Graphics.FreeGame.Base: GetGameParam :: (GameParam -> a) -> GameAction a
+ Graphics.FreeGame.Base: getCurrentGameParam :: MonadFree GameAction m => m GameParam
+ Graphics.FreeGame.Base: instance Show GameParam
+ Graphics.FreeGame.Simple: data Bitmap
Files
- Graphics/FreeGame/Backends/GLFW.hs +23/−5
- Graphics/FreeGame/Base.hs +8/−1
- Graphics/FreeGame/Simple.hs +1/−0
- free-game.cabal +1/−1
Graphics/FreeGame/Backends/GLFW.hs view
@@ -106,6 +106,8 @@ , ?refTextures :: IORef (IM.IntMap Texture) , ?refFrame :: IORef Int , ?frameTime :: Double + , ?windowTitle :: String, ?windowMode :: Bool + , ?cursorVisible :: Bool ) => [Int] -> Game a -> IO (Maybe a) run is (Pure x) = do m <- readIORef ?refTextures @@ -143,9 +145,22 @@ (x, y) <- getMousePosition b0 <- mouseButtonIsPressed MouseButton0 b1 <- mouseButtonIsPressed MouseButton1 - b2 <- mouseButtonIsPressed MouseButton1 + b2 <- mouseButtonIsPressed MouseButton2 w <- getMouseWheel run is $ fcont $ I.MouseState (Vec2 (fromIntegral x) (fromIntegral y)) b0 b2 b1 w + GetGameParam fcont -> do + dim <- GLFW.getWindowDimensions + GL.Color4 r g b a <- get GL.clearColor + run is $ fcont $ GameParam { framePerSecond = floor $ 1 / ?frameTime + , windowSize = dim + , windowTitle = ?windowTitle + , windowed = ?windowMode + , cursorVisible = ?cursorVisible + , clearColor = Color (realToFrac r) + (realToFrac g) + (realToFrac b) + (realToFrac a) + } QuitGame -> return Nothing -- | Run 'Game' using OpenGL and GLFW. @@ -155,19 +170,22 @@ pf <- openGLProfile let ?windowWidth = fst $ windowSize param ?windowHeight = snd $ windowSize param - + ?windowTitle = windowTitle param + ?windowMode = windowed param + ?cursorVisible = cursorVisible param openWindow $ defaultDisplayOptions { displayOptions_width = fromIntegral ?windowWidth ,displayOptions_height = fromIntegral ?windowHeight - ,displayOptions_displayMode = Window + ,displayOptions_displayMode = if ?windowMode then Window else Fullscreen ,displayOptions_windowIsResizable = False ,displayOptions_openGLProfile = pf ,displayOptions_numDepthBits = 8 } - unless (cursorVisible param) $ disableMouseCursor + if ?cursorVisible then enableMouseCursor + else disableMouseCursor - setWindowTitle $ windowTitle param + setWindowTitle $ ?windowTitle GL.lineSmooth $= GL.Enabled GL.blend $= GL.Enabled
Graphics/FreeGame/Base.hs view
@@ -36,6 +36,7 @@ -- * Settings ,GameParam(..) ,defaultGameParam + ,getCurrentGameParam -- * Deprecated ,loadPicture @@ -64,12 +65,14 @@ | DrawPicture Picture a | AskInput Key (Bool -> a) | GetMouseState (MouseState -> a) + | GetGameParam (GameParam -> a) | QuitGame instance Functor GameAction where fmap f (DrawPicture a cont) = DrawPicture a (f cont) fmap f (AskInput a cont) = AskInput a (f . cont) fmap f (GetMouseState cont) = GetMouseState (f . cont) + fmap f (GetGameParam cont) = GetGameParam (f . cont) fmap f (EmbedIO m) = EmbedIO (fmap f m) fmap f (Bracket m) = Bracket (fmap f m) fmap f (Tick cont) = Tick (f cont) @@ -103,6 +106,10 @@ getMouseState :: MonadFree GameAction m => m MouseState getMouseState = wrap $ GetMouseState return +-- | Get the game params that apply to the currently running game. +getCurrentGameParam :: MonadFree GameAction m => m GameParam +getCurrentGameParam = wrap $ GetGameParam return + -- | Lift a picture transformation into transformation of 'GameAction' transPicture :: (Picture -> Picture) -> GameAction cont -> GameAction cont transPicture f (DrawPicture p cont) = DrawPicture (f p) cont @@ -133,7 +140,7 @@ ,windowed :: Bool ,cursorVisible :: Bool ,clearColor :: Color - } + } deriving Show -- | 640*480(windowed), 60fps defaultGameParam :: GameParam
Graphics/FreeGame/Simple.hs view
@@ -30,6 +30,7 @@ -- * About Picture ,Picture(..) + ,Bitmap ,loadBitmapFromFile ,Vec2(..)
free-game.cabal view
@@ -1,5 +1,5 @@ name: free-game -version: 0.3.1.3 +version: 0.3.1.4 synopsis: Create graphical applications for free. description: Cross-platform GUI library based on free monads. homepage: https://github.com/fumieval/free-game