gloss-game-0.3.3.0: Gloss wrapper that simplifies writing games

Portabilityhaskell2011
MaintainerManuel M T Chakravarty <chak@cse.unsw.edu.au>
Safe HaskellNone

Graphics.Gloss.Game

Contents

Description

 

Synopsis

Reexport some basic Gloss datatypes

Geometry

type SizeSource

Arguments

 = (Float, Float)

width & height

type RectSource

Arguments

 = (Point, Size)

origin & extent, where the origin is at the centre

Load sprites into pictures

bmp :: FilePath -> PictureSource

Turn a bitmap file into a picture.

NB: Define loaded pictures on the toplevel to avoid reloading.

png :: FilePath -> PictureSource

Turn a PNG file into a picture.

NB: Define loaded pictures on the toplevel to avoid reloading.

jpg :: FilePath -> PictureSource

Turn a JPEG file into a picture.

NB: Define loaded pictures on the toplevel to avoid reloading.

Query pictures

boundingBox :: Picture -> RectSource

Determine the bounding box of a picture.

FIXME: Current implementation is incomplete!

More convenient game play

playSource

Arguments

:: Display

Display mode

-> Color

Background color

-> Int

Number of simulation steps to take for each second of real time

-> world

The initial world state

-> (world -> Picture)

A function to convert the world to a picture

-> (Event -> world -> world)

A function to handle individual input events

-> [Float -> world -> world]

Set of functions invoked once per iteration — first argument is the period of time (in seconds) needing to be advanced

-> IO () 

Play a game.

playInSceneSource

Arguments

:: Display

Display mode

-> Color

Background color

-> Int

Number of simulation steps to take for each second of real time

-> world

The initial world state

-> Scene world

A scene parameterised by the world

-> (Float -> Event -> world -> world)

A function to handle individual input events * first argument is the absolute time (in seconds)

-> [Float -> Float -> world -> world]

Set of functions invoked once per iteration — * first argument is the absolute time (in seconds) * second argument is the period of time needing to be advanced

-> IO () 

Play a game in a scene.

Game scenes

data Animation Source

An abstract representation of an animation.

animation :: [Picture] -> Float -> Float -> AnimationSource

Construct a new animation with a list of pictures for the animation, the time between animation frames, and a given (absolute) start time.

noAnimation :: AnimationSource

An empty animation.

data Scene world Source

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.

picture :: Picture -> Scene worldSource

Turn a static picture into a scene.

picturing :: (world -> Picture) -> Scene worldSource

Turn a world-dependent picture into a scene.

animating :: (world -> Animation) -> Picture -> Scene worldSource

Animate a world-dependent animation. The default picture is displayed while no animation is running.

translating :: (world -> Point) -> Scene world -> Scene worldSource

Move a scene in dependences on a world-dependent location.

rotating :: (world -> Float) -> Scene world -> Scene worldSource

Rotate a scene in dependences on a world-dependent angle.

scaling :: (world -> (Float, Float)) -> Scene world -> Scene worldSource

Scale a scene in dependences on world-dependent scaling factors.

scenes :: [Scene world] -> Scene worldSource

Compose a scene from a list of scenes.

drawScene :: Scene world -> Float -> world -> PictureSource

Render a scene on the basis of time since playing started and the specific world state.