free-game 1.0 → 1.0.1
raw patch · 5 files changed
+56/−6 lines, 5 files
Files
- FreeGame.hs +7/−2
- FreeGame/Class.hs +7/−0
- FreeGame/Data/Bitmap.hs +5/−1
- FreeGame/Util.hs +36/−2
- free-game.cabal +1/−1
FreeGame.hs view
@@ -43,6 +43,7 @@ -- * Keyboard Keyboard(..), Key(..), + charToKey, keyPress, keyUp, keyDown, @@ -77,7 +78,12 @@ module Linear, -- * Deprecated fromBitmap, - colored + loadBitmapFromFile, + colored, + tick, + keyChar, + keySpecial + ) where import FreeGame.UI @@ -110,7 +116,6 @@ -- When we run @foo@ using 'runGame', a blue square follows the cursor. -- And 'translate' (V2 240 240) @foo@, 'rotate' 45 @foo@, 'scale' 1.5 @foo@ also does in the same way. -- --- You have to call 'tick' at the end of the frame. -- -- The only way to embody a 'Game' as a real stuff is to apply 'runGame'. --
FreeGame/Class.hs view
@@ -22,6 +22,13 @@ import Control.Monad.IO.Class import qualified Data.Map as Map +infixr 5 `translate` +infixr 5 `rotateR` +infixr 5 `rotateD` +infixr 5 `scale` +infixr 5 `color` +infixr 5 `colored` + class Functor p => Affine p where -- | (radians) rotateR :: Double -> p a -> p a
FreeGame/Data/Bitmap.hs view
@@ -21,7 +21,7 @@ -- * Load and Save ,readBitmap ,writeBitmap - + , loadBitmapFromFile -- * Constructing bitmaps ,toBitmap ,toStableBitmap @@ -85,6 +85,10 @@ -- | Load an image file. readBitmap :: MonadIO m => FilePath -> m Bitmap readBitmap path = liftIO $ readImageRGBA path >>= either fail return >>= makeStableBitmap . imgData + +{-# DEPRECATED loadBitmapFromFile "use readBitmap instead" #-} +loadBitmapFromFile :: MonadIO m => FilePath -> m Bitmap +loadBitmapFromFile = readBitmap -- | Save 'Bitmap' into a file. writeBitmap :: MonadIO m => FilePath -> Bitmap -> m ()
FreeGame/Util.hs view
@@ -28,7 +28,11 @@ -- * Loading loadPictureFromFile, loadBitmaps, - loadBitmapsWith + loadBitmapsWith, + -- * Keyboard + charToKey, + keyChar, + keySpecial ) where import Control.Applicative @@ -41,6 +45,7 @@ import Data.Void import FreeGame.Data.Bitmap import FreeGame.Class +import FreeGame.Types import Language.Haskell.TH import Linear import System.Directory @@ -50,6 +55,7 @@ import System.Environment -- | Delimit the computation to yield a frame. +{-# DEPRECATED tick "use delay or foreverFrame instead" #-} tick :: (Monad f, MonadFree f m) => m () tick = delay (return ()) @@ -141,4 +147,32 @@ pathToName :: FilePath -> String pathToName = ('_':) . map p where p c | isAlphaNum c = c - | otherwise = '_'+ | otherwise = '_' + +charToKey :: Char -> Key +charToKey ch + | isAlpha ch = toEnum $ fromEnum KeyA + fromEnum ch - fromEnum 'A' + | isDigit ch = toEnum $ fromEnum Key0 + fromEnum ch - fromEnum '0' +charToKey '-' = KeyMinus +charToKey ',' = KeyComma +charToKey '.' = KeyPeriod +charToKey '/' = KeySlash +charToKey ' ' = KeySpace +charToKey '\'' = KeyApostrophe +charToKey '\\' = KeyBackslash +charToKey '=' = KeyEqual +charToKey ';' = KeySemicolon +charToKey '[' = KeyLeftBracket +charToKey ']' = KeyRightBracket +charToKey '`' = KeyGraveAccent +charToKey '\n' = KeyEnter +charToKey '\r' = KeyEnter +charToKey '\t' = KeyTab +charToKey _ = KeyUnknown + +keyChar :: Keyboard f => Char -> f Bool +keyChar = keyPress . charToKey + +{-# DEPRECATED keySpecial "use keyPress instead" #-} +keySpecial :: Keyboard f => Key -> f Bool +keySpecial = keyPress
free-game.cabal view
@@ -1,5 +1,5 @@ name: free-game -version: 1.0 +version: 1.0.1 synopsis: Create games for free description: free-game defines a monad that integrates features to create 2D games.