[Haskell-cafe] Programming videogames in haskell

sean.seefried at gmail.com sean.seefried at gmail.com
Sat Nov 15 01:25:47 UTC 2014

Hi Quentin,

I am currently building a game in Haskell that I plan to deploy to iOS and Android. It’s built using a combination
of SDL2 and Cairo (for vector graphics) and Hipmunk (for physics via the Chipmunk C library).

As in Ivan Perez's case I’m not using the Hackage versions of the SDL2 bindings. Instead I’m using the versions
found on Github at [1] and [2].

I have recently managed to deploy my game to Android but this has not been a straightforward process. Building a GHC cross compiler for ARM was a time consuming process but greatly aided by the using the script found in the
stable-ghc-snapshot branch of joehy’s repo on Github [3]. Building all the libraries I needed was even less straightforward. (I’ve written more about this in a post script) 

Deploying to iOS should be a much more straightforward process since there is official GHC support for iOS and you can download a binary distribution of the cross compiler at [4]. (Scroll down to find Luke Iannini’s distribution. Luke Iannini, Steven Blackheath put in a lot of hard work over many months to provide iOS support for GHC.)

I’ve also had a play around with Helm which uses the Elerea FRP library, SDL2 and Cairo. I think it’s a pretty good little library for prototyping, although you will need to learn FRP (Functional Reactive Programming) in the process.



p.s. Here is a little more detail on targeting ARM. Many of the libraries, notably the SDL2 binding, did not work out of the box with a cross compiler since they did not use Cabal’s Distribution.Simple and required that Setup.hs was compiled and run. Unfortunately this just does not work with a cross-compiler since you can’t run the code on your host machine. The work around is to build it using GHC targeting the host machine and to run that. This works okay, but a straight “cabal install” will not. A more serious problem I ran into was that the SDL2 binding requires the use of hsc2c. hsc2c has a --cross-compile flag but it does not support all of the hsc2c directives, specifically the “let” directive which is used by SDL2. 

[1] https://github.com/Lemmih/hsSDL2
[2] https://github.com/jdeseno/hs-sdl2-mixer
[3] https://github.com/joeyh/ghc-android
[4] https://www.haskell.org/ghc/download_ghc_7_8_3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20141115/97102fc0/attachment.html>

More information about the Haskell-Cafe mailing list