HPong 0.1.2

About two days ago the beta version of the Haskell Platform was released. Since it comes with an OpenGL library, it is now trivially easy to start making OpenGL programs with Haskell. To test this, I decided to make a simple Pong clone for two reasons:

To experiment with making an OpenGL game

I chose to use the GLFW instead of the GLUT library because GLUT doesn’t respond to closing a window with the close button very well. However, I could only find one piece of sample code for GLFW. Because of that, I decided to make a small game that others can use as a starting point for their own games.

The controls are very simple: The up and down arrow keys move your paddle and Esc quits the game.

Below is the complete code for HPong; 136 lines, including blank lines. Basic concepts include rendering the game, showing FPS and responding to keyboard input. The code is published as GPL and available from Hackage here. Have fun making your own games!

Like this:

Related

This entry was posted on April 23, 2009 at 5:03 pm and is filed under Games. You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.

For anyone who tries to run this on OS X but can’t get the window to accept focus, you need to put the binary in an application bundle. I’m not sure why you have to do this, but making a C++ Carbon project in Xcode called hpong and replacing the executable with the hpong installed by cabal works.