Helm is currently looking for co-maintainers. If you would like to help to develop Helm further, please contact me.
Helm is a purely functional game engine written in Haskell and built with the Elerea functionally-reactive programming framework and SDL2. Helm was originally inspired by the Elm programming language.
In Helm, every piece of input that can be gathered from a user (or the operating system) is contained in a subscription, which is essentially as a collection of input events changing over time mapped to game interactions.
Think of it this way - when you hold down the w and a keys, two keyboard events are being captured at every moment.
You might want your game to move your character forward by pressing w
.
When you add a subscription to your game, you choose how to map these two input events
into a game action type (which you provide, the engine doesn't have any concept
of how the action works). So if you mapped the w
key to some game action variant (game
actions are usually represented as a collection of data type variants), and the w
key was held down,
then at every game tick the game would produce a w
key press event and turn this into
the relevant game action.
On top of subscriptions, Helm has another core concept called commands. Commands are essentially IO-like monads that have context about the engine state. Like subscriptions, commands are mapped directly to game actions. This means that when interacting with IO through Helm, you directly specify how the result maps to a game action and allows you to make logical conclusions about how certain monadic results should interact with your game.
Helm provides a structure familiar to MVC-based framework developers. There is a model (which represents the state of your game), a view of the current model (i.e. what's actually shown on the screen) and a function similiar to a controller that folds the model forward based off of input actions (which are in turn mapped to from subscription events).
This presents a powerful paradigm shift for game development. Instead of writing event listeners, Helm treats input events as first-class citizens of the type system, and the actual interaction between the game state and input events becomes immediately clearer.
Helm.Color
Helm.Graphics2D
Helm.Graphics2D.Text
Helm.Graphics2D.Transform
Helm.Keyboard
Helm.Mouse
Helm.Cmd
Helm.Sub
Helm.Time
Helm.Window
Before you can use Helm, you'll to follow the Gtk2Hs installation guide (which is required for the Haskell Cairo bindings). Additionally, Helm requires a GHC version of 7.6 or higher.
Using Stack when working with Helm is recommended. To install Helm with Stack, use:
stack install helm
It's best to add Helm as a dependency in your game's Cabal file rather than installing it globally, however if you're new to the engine, installing it globally will let you run the example Helm games. See the next section.
Check out the examples
directory for some examples; the hello
example is a
particularly good start and flappy
is a bit more advanced. We could always
use more examples so if you end up making something cool and lightweight that
you'd think would be a good one, feel free to open a pull request!
If you have installed Helm globally using Stack, you can run the flappy
example using:
stack exec helm-example-flappy
Or the hello
example using:
stack exec helm-example-hello
API documentation for the latest stable version of Helm is available on Hackage. Alternatively, if you've cloned this repo, you can build the documentation manually using Haddock.
Helm is licensed under the MIT license. See the LICENSE file for more details.
Helm would benefit from either of the following contributions: