Frag — a first-person shooter by Mun Hon Cheong written in Haskell using GLUT and OpenGL.
This tutorial describes a quick overview and steps on how to get started in game development with Haskell and Ubuntu 10.04.
In case you just want to see some examples get the newest Haskell platform package. Just type in console (you may want to update the download URL):
tar zxf haskell-platform-2010.1.0.0.tar.gz
sudo make install
sudo echo PATH=$PATH:~/.cabal/bin
cabal install cabal-install
See Hackage games for a list of games written in Haskell. To install and run Frag f.e., type in console:
cabal unpack frag
This should be sufficient for all other games, some need external libraries however (i.e. “sudo apt-get install lib…”).
If you are used to visual IDEs like Visual Studio or Eclipse (and want to avoid Vim or Emacs) you may consider the following 2 Haskell IDEs (don’t expect too much though @May 2010):
- EclipseFP: just basic functionality
- Leksah: very buggy on Linux, I didn’t even get the modules to show up, but has good package configurator
I stuck with EclipseFP. To install EclipseFP, type in console:
git clone http://github.com/JPMoresmau/scion.git
in Eclipse do:
- Help -> Install new software -> Add -> “EclipseFP — http://eclipsefp.sf.net/updates”
- Window -> Open perspective… -> Haskell
The Haskell community and libraries are still in heavy development, again don’t expect too much (@May 2010). Basically there are the following libraries available which you might be interested:
- SDL: libsdl is a very mature and widespread library collection for 2D graphics and input (see also SDL-gfx, SDL-image, SDL-mixer, SDL-mpeg, SDL-ttf). tutorials available at: LazyFooHaskell, Animal-Machine.Com and all original SDL tutorials
- hogre: Haskell bindings to a subset of the popular OGRE graphics engine, includes 3 small examples, library looks very clean, no documentation. note the version number though (build no. 3, no more activity). Couldn’t get it running on Windows 7 or Ubuntu, even with OGRE 1.6.4 or 1.7.1.
- lambdacube-engine: pure functional graphics engine, includes some examples and runs out-of-the-box. note the version number though (build no. 2, no more activity)
- HGL based on book The Haskell School of Expression
- GLFW, GLUT, GLUT: as a last option, doing the low-level stuff manually
I stuck with SDL (standard in 2D, quite mature, input handling included). To install SDL, type in console:
cabal install SDL SDL-gfx SDL-image SDL-mixer SDL-mpeg SDL-ttf
Reactive programming (or more precise temporal programming with events) abstracts away time and events which is very useful in game development as most games are interactive real-time simulations. Use: Yampa! It’s maintained by the Yale Haskell Group, very mature, the 5th iteration or so of a reactive programming library especially designed for games and there are also some scientific papers available.
- Yampa homepage
- A Brief Introduction to Functional Reactive Programming and Yampa (slides)
- Functional Reactive Programming (slides)
- Functional Programming and 3D Games (paper, 2005)
- The Yampa Arcade (paper, 2003)
- Functional Reactive Programming, Continued (paper, 2002)
Also check out these blogs: