Sami Hangaslammi edited this page Jul 26, 2011 · 24 revisions



I'll start with a disclaimer that I have myself only started learning Haskell a little while ago, so this series of articles isn't so much about me trying to teach others, but rather something that I'm doing to improve my own grasp of both Haskell and OpenGL, and to see for myself how well Haskell is suited for game programming.

The idea is to implement the classic game of Asteroids using Haskell, OpenGL and GLUT. I'm not a big fan of GLUT actually, but in order to make it easy for anyone to compile the program on Windows, Linux and MacOSX, I'm restricting myself to libraries that are available pre-built with the Haskell Platform.

The first part will setup all the boring boilerplate required to get us running an OpenGL window, and after that we'll gradually build the game in small iterations, each of which adds some small new functionality to the game. The aim is to isolate the OpenGL code as much as possible from the actual game code, and to use pure functions and immutable data structures whenever possible. In the last part, we'll look at how the game performs, and possibly optimize some parts to use mutable data structures and shared global state, if necessary.