A library with a small scaffolding for creating simple games.
Platform.Program () s (GameEvent e)
A simple game, with state type s
and event type e
.
game : { init : s, update : GameEvent e -> s -> s, view : s -> ElmTeachingTools.Lib.Graphics.Screen e } -> Game s e
Create a game.
This follows the State Machine program architecture. We must provide:
s
of possible program states,e
of possible custom events,init : s
,update : GameEvent e -> s -> s
, andview : s -> Screen e
This framework comes with some built-in events. Specifically,
GameEvent
can be a ClockTick
event, a Keyboard
event,
or it can be a Custom
event with type e
.
Basics.Int
The number of milliseconds since Midnight UTC Jan 1 1970.
Note: You can tell how much time has elapsed in your game by saving the start time in your game state and then subtracting later on.
Events that your game can respond to.
A ClockTick
event occurs about 60 times per second and carries the
current timestamp.
A Keyboard
event occurs whenever a key is pushed down or released
(see Lib.Keyboard
).
A Custom
event can be triggered by the onClick
property of a
Graphic
element (see Lib.Graphics
).