free-game- Create graphical applications for free.

MaintainerFumiaki Kinsohita <>
Safe HaskellNone




The essentials of using free-game


Basic type

type Game = Free GameActionSource

Game is a Monad that abstracts user interfaces.

Run the game

defaultGameParam :: GameParamSource

640*480(windowed), 60fps



:: 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.

In the Game monad

askInput :: MonadFree GameAction m => Key -> m BoolSource

Is the specified Key is pressed?

getMouseState :: MonadFree GameAction m => m MouseStateSource

Get the mouse's state.

embedIO :: MonadFree GameAction m => IO a -> m aSource

Embed arbitrary IO actions into a Game monad.

quitGame :: MonadFree GameAction m => m aSource

Break the current computation.

tick :: MonadFree GameAction m => m ()Source

Finalize the current frame and refresh the screen.

untickGame :: Game a -> Game (Game a)Source

Run a Game as one frame.

About Picture

data Picture Source

A 2D Picture.


BitmapPicture Bitmap

A Bitmap as a Picture.

Pictures [Picture]

A picture consist of some Pictures.

IOPicture (IO Picture)

A picture that may have side effects.

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.

loadBitmapFromFile :: FilePath -> IO BitmapSource

Create a Bitmap from the given file.

Drawing texts

loadFont :: FilePath -> IO FontSource

Create a Font from the given file.

text :: Font -> Float -> Color -> String -> PictureSource

Render a text by the specified Font and Color and size.


randomness :: (Random r, MonadFree GameAction m) => (r, r) -> m rSource

Get a given range of value.