| Portability | non-portable |
|---|---|
| Stability | provisional |
| Maintainer | Fumiaki Kinsohita <fumiexcel@gmail.com> |
| Safe Haskell | None |
Graphics.FreeGame.Simple
Contents
Description
The essentials of using free-game
- type Game = Free GameAction
- data GameAction a
- data GameParam = GameParam {
- framePerSecond :: Int
- windowSize :: (Int, Int)
- windowTitle :: String
- windowed :: Bool
- cursorVisible :: Bool
- clearColor :: Color
- windowOrigin :: Vec2
- defaultGameParam :: GameParam
- runSimple :: GameParam -> world -> (world -> Game world) -> IO ()
- runSimple' :: GameParam -> world -> (world -> forall m. MonadFree GameAction m => m world) -> IO ()
- drawPicture :: MonadFree GameAction m => Picture -> m ()
- getButtonState :: MonadFree GameAction m => Button -> m Bool
- getMousePosition :: MonadFree GameAction m => m Vec2
- getMouseWheel :: MonadFree GameAction m => m Int
- embedIO :: MonadFree GameAction m => IO a -> m a
- quitGame :: MonadFree GameAction m => m Void
- tick :: MonadFree GameAction m => m ()
- untick :: MonadFree GameAction m => Free GameAction a -> m (Either (Free GameAction a) a)
- untickInfinite :: MonadFree GameAction m => Free GameAction Void -> m (Free GameAction Void)
- untickGame :: MonadFree GameAction m => Free GameAction a -> m (Free GameAction a)
- data Picture
- data Bitmap
- loadBitmapFromFile :: FilePath -> IO Bitmap
- loadBitmaps :: FilePath -> Q [Dec]
- loadBitmapsWith :: Name -> FilePath -> Q [Dec]
- data Vec2 = Vec2 !Float !Float
- data Font
- loadFont :: FilePath -> IO Font
- text :: Font -> Float -> String -> Picture
- randomness :: (Random r, MonadFree GameAction m) => (r, r) -> m r
- degrees :: Float -> Float
- askInput :: MonadFree GameAction m => Button -> m Bool
- getMouseState :: MonadFree GameAction m => m MouseState
- module Graphics.FreeGame.Input
- module Graphics.FreeGame.Data.Color
Basic type
Run the game
Parameters of the application.
Constructors
| GameParam | |
Fields
| |
defaultGameParam :: GameParamSource
640*480(windowed), 60fps
Arguments
| :: GameParam | |
| -> world | An initial world |
| -> (world -> Game world) | A computation yielding new world |
| -> IO () |
Run a Game by the given initial state and updating function.
Arguments
| :: GameParam | |
| -> world | An initial world |
| -> (world -> forall m. MonadFree GameAction m => m world) | A computation yielding new world |
| -> IO () |
In the Game monad
drawPicture :: MonadFree GameAction m => Picture -> m ()Source
Draw a Picture.
getButtonState :: MonadFree GameAction m => Button -> m BoolSource
Is the specified Button is pressed?
getMousePosition :: MonadFree GameAction m => m Vec2Source
getMouseWheel :: MonadFree GameAction m => m IntSource
quitGame :: MonadFree GameAction m => m VoidSource
Break the current computation.
tick :: MonadFree GameAction m => m ()Source
Finalize the current frame and refresh the screen.
untick :: MonadFree GameAction m => Free GameAction a -> m (Either (Free GameAction a) a)Source
Run a Game as one frame.
untickInfinite :: MonadFree GameAction m => Free GameAction Void -> m (Free GameAction Void)Source
An infinite version of untick.
untickGame :: MonadFree GameAction m => Free GameAction a -> m (Free GameAction a)Source
Deprecated: use untick or untickInfinite instead
About Picture
A 2D Picture.
Constructors
| Bitmap Bitmap | |
| BitmapPicture Bitmap | Deprecated: use Bitmap instead Deprecated synonym for |
| Pictures [Picture] | A picture consist of some |
| PictureWithFinalizer (FinalizerT IO Picture) | A picture that may have side effects(internal use only). |
| Rotate Float Picture | Rotated picture by the given angle (in degrees, counterclockwise). |
| Scale Vec2 Picture | Scaled picture. |
| Translate Vec2 Picture | A picture translated by the given coordinate. |
| Colored Color Picture | Colored picture. |
loadBitmaps :: FilePath -> Q [Dec]Source
use with getDataFileName
loadBitmapsWith :: Name -> FilePath -> Q [Dec]Source
Load and define all pictures in the specified directory.
data Vec2
Instances
Drawing texts
Utilities
randomness :: (Random r, MonadFree GameAction m) => (r, r) -> m rSource
Get a given range of value.
Deprecated
askInput :: MonadFree GameAction m => Button -> m BoolSource
Deprecated: use getButtonState instead.
Deprecated synonym for getButtonState.
getMouseState :: MonadFree GameAction m => m MouseStateSource
Deprecated: use getMousePosition and getMouseWheel instead.
Yields the mouse's state.
Reexports
module Graphics.FreeGame.Input
module Graphics.FreeGame.Data.Color