
Reprinted from my blog post [1]: === The semester is over, my final project was a success (at least in that I passed the class) and it’s time now to release the game I made for Graphics 455: Silkworm! This is my first full application in Haskell. The process has been an enlarging experience–I’ve come to really enjoy the mental work that goes into thinking about a program in a functional way. I highly recommend the challenge to other software engineers. Silkworm combines the Hipmunk binding to Chipmunk 2D Game Dynamics with OpenGL, and GLFW (an alternative to GLUT). It’s built to work on Mac OS X, but it uses cross-platform libraries so it should be fairly easy to port to other platforms. The source code is here [2] and below are some screenshots [1] -- Duane Johnson (canadaduane) === [1] http://blog.inquirylabs.com/2009/05/02/silkworm-game-written-in-haskell/ [2] http://inquirylabs.com/downloads/Silkworm.tgz

Excellent work! Time to upload to hackage?? -- Don duane.johnson:
Reprinted from my blog post [1]:
===
The semester is over, my final project was a success (at least in that I passed the class) and it’s time now to release the game I made for Graphics 455: Silkworm!
This is my first full application in Haskell. The process has been an enlarging experience–I’ve come to really enjoy the mental work that goes into thinking about a program in a functional way. I highly recommend the challenge to other software engineers.
Silkworm combines the Hipmunk binding to Chipmunk 2D Game Dynamics with OpenGL, and GLFW (an alternative to GLUT).
It’s built to work on Mac OS X, but it uses cross-platform libraries so it should be fairly easy to port to other platforms. The source code is here [2] and below are some screenshots [1]
-- Duane Johnson (canadaduane)
===
[1] http://blog.inquirylabs.com/2009/05/02/silkworm-game-written-in-haskell/ [2] http://inquirylabs.com/downloads/Silkworm.tgz_______________________________... Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hi! On Sat, May 02, 2009 at 01:00:23PM -0600, Duane Johnson wrote:
Silkworm combines the Hipmunk binding to Chipmunk 2D Game Dynamics with OpenGL, and GLFW (an alternative to GLUT).
It's great to see Hipmunk being useful to someone :). I've written the binding to turn some of my ideas into code but I've never finished any of them. -- Felipe.

Thanks, Felipe! Indeed, it was a wonderful surprise to see a 2D physics engine binding for Haskell. It made it possible for me to choose Haskell as my implementation language. I'm very grateful for that. I wish you luck (and time!) in implementing your ideas :) Regards, Duane On May 2, 2009, at 2:44 PM, Felipe Lessa wrote:
Hi!
On Sat, May 02, 2009 at 01:00:23PM -0600, Duane Johnson wrote:
Silkworm combines the Hipmunk binding to Chipmunk 2D Game Dynamics with OpenGL, and GLFW (an alternative to GLUT).
It's great to see Hipmunk being useful to someone :). I've written the binding to turn some of my ideas into code but I've never finished any of them.
-- Felipe. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Congratulations!!! It is actually a fun game to play too :-)
On Sat, May 2, 2009 at 9:00 PM, Duane Johnson
Reprinted from my blog post [1]:
===
The semester is over, my final project was a success (at least in that I passed the class) and it’s time now to release the game I made for Graphics 455: Silkworm!
This is my first full application in Haskell. The process has been an enlarging experience–I’ve come to really enjoy the mental work that goes into thinking about a program in a functional way. I highly recommend the challenge to other software engineers.
Silkworm combines the Hipmunk binding to Chipmunk 2D Game Dynamics with OpenGL, and GLFW (an alternative to GLUT).
It’s built to work on Mac OS X, but it uses cross-platform libraries so it should be fairly easy to port to other platforms. The source code is here [2] and below are some screenshots [1]
-- Duane Johnson (canadaduane)
===
[1] http://blog.inquirylabs.com/2009/05/02/silkworm-game-written-in-haskell/ [2] http://inquirylabs.com/downloads/Silkworm.tgz_______________________________... Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Yes, it is quite fun. I think it should be using cabal's datadir from Paths_silkworm.hs to install (and find) the resources. Yell if you can't figure out how to do that. (xmonad has an example) -- Don bugfact:
Congratulations!!! It is actually a fun game to play too :-)
On Sat, May 2, 2009 at 9:00 PM, Duane Johnson
wrote: Reprinted from my blog post [1]:
===
The semester is over, my final project was a success (at least in that I passed the class) and it s time now to release the game I made for Graphics 455: Silkworm!
This is my first full application in Haskell. The process has been an enlarging experience I ve come to really enjoy the mental work that goes into thinking about a program in a functional way. I highly recommend the challenge to other software engineers.
Silkworm combines the Hipmunk binding to Chipmunk 2D Game Dynamics with OpenGL, and GLFW (an alternative to GLUT).
It s built to work on Mac OS X, but it uses cross-platform libraries so it should be fairly easy to port to other platforms. The source code is here [2] and below are some screenshots [1]
-- Duane Johnson (canadaduane)
===
[1] http://blog.inquirylabs.com/2009/05/02/silkworm-game-written-in-haskell / [2] http://inquirylabs.com/downloads/ Silkworm.tgz_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

So here's the thing.... to get it to run on Mac OS X, I have to build a "SilkwormGame.app" directory, with a "Resources" directory inside, along with a lot of other rubbish, just so that GLFW can create a Mac OS window that accepts mouse and keyboard input. This is the purpose of the Makefile--it uses a script borrowed from wxWindows to assemble all the parts. Obviously, this rigamarole is not necessary in Unix. But am I correct in assuming that there is no facility in Cabal that prepares a Mac OS "app" in this way? Any suggestions so that a cabal install will work for both Unix and Mac users? Here is what I get (using Don's Silkworm.cabal):
~/Documents/Duane/BYU Semesters/2009-Winter/Graphics/ Silkworm(master) $ cabal install Resolving dependencies... Configuring Silkworm-0.2... Preprocessing executables for Silkworm-0.2... Building Silkworm-0.2... [ 1 of 16] Compiling Silkworm.Action ( Silkworm/Action.hs, dist/ build/SilkwormGame/SilkwormGame-tmp/Silkworm/Action.o ) ... <snip>... [16 of 16] Compiling Main ( main.hs, dist/build/ SilkwormGame/SilkwormGame-tmp/Main.o ) Linking dist/build/SilkwormGame/SilkwormGame ... Installing executable(s) in /Users/duane/.cabal/bin
~/Silkworm(master) $ SilkwormGame Working in unbundled mode. You should build a .app wrapper for your Mac OS X applications. SilkwormGame: ~/Silkworm/background.png: openBinaryFile: does not exist (No such file or directory)
Putting the binary files in the place it expects produces the same "working in unbundled mode" along with a window that will not capture ANY input from the mouse or keyboard. In fact, it won't even rise to the top of the window stack--it remains behind the terminal window. Thanks for you help, -- Duane On May 2, 2009, at 6:07 PM, Don Stewart wrote:
Yes, it is quite fun.
I think it should be using cabal's datadir from Paths_silkworm.hs to install (and find) the resources.
Yell if you can't figure out how to do that. (xmonad has an example)
-- Don

For the Mac, you might have to use mkbndl or one of the other native package builders for the Mac. -- Don duane.johnson:
So here's the thing.... to get it to run on Mac OS X, I have to build a "SilkwormGame.app" directory, with a "Resources" directory inside, along with a lot of other rubbish, just so that GLFW can create a Mac OS window that accepts mouse and keyboard input. This is the purpose of the Makefile--it uses a script borrowed from wxWindows to assemble all the parts.
Obviously, this rigamarole is not necessary in Unix. But am I correct in assuming that there is no facility in Cabal that prepares a Mac OS "app" in this way? Any suggestions so that a cabal install will work for both Unix and Mac users?
Here is what I get (using Don's Silkworm.cabal):
~/Documents/Duane/BYU Semesters/2009-Winter/Graphics/Silkworm(master) $ cabal install Resolving dependencies... Configuring Silkworm-0.2... Preprocessing executables for Silkworm-0.2... Building Silkworm-0.2... [ 1 of 16] Compiling Silkworm.Action ( Silkworm/Action.hs, dist/ build/SilkwormGame/SilkwormGame-tmp/Silkworm/Action.o ) ... <snip>... [16 of 16] Compiling Main ( main.hs, dist/build/ SilkwormGame/SilkwormGame-tmp/Main.o ) Linking dist/build/SilkwormGame/SilkwormGame ... Installing executable(s) in /Users/duane/.cabal/bin
~/Silkworm(master) $ SilkwormGame Working in unbundled mode. You should build a .app wrapper for your Mac OS X applications. SilkwormGame: ~/Silkworm/background.png: openBinaryFile: does not exist (No such file or directory)
Putting the binary files in the place it expects produces the same "working in unbundled mode" along with a window that will not capture ANY input from the mouse or keyboard. In fact, it won't even rise to the top of the window stack--it remains behind the terminal window.
Thanks for you help, -- Duane
On May 2, 2009, at 6:07 PM, Don Stewart wrote:
Yes, it is quite fun.
I think it should be using cabal's datadir from Paths_silkworm.hs to install (and find) the resources.
Yell if you can't figure out how to do that. (xmonad has an example)
-- Don

Nice work! Two minor suggestions, apart from the the paths issue already discussed here: * Either include a license file in the source distribution or remove the corresponding line in the .cabal file. Cabal won't work if it is specified and missing. * List all your build dependencies directly, so users can simply do a "cabal install", pulling all missing dependencies automatically. No need for Makefiles or a long description in the README anymore... Patch for those items attached. As a side note, I get a very bad feeling when Hipmunk gets compiled on my x86_64 box: chipmunk/cpCollision.c: In function ‘findVerts’: chipmunk/cpCollision.c:174:0: warning: cast from pointer to integer of different size chipmunk/cpCollision.c:180:0: warning: cast from pointer to integer of different size chipmunk/cpCollision.c: In function ‘findPointsBehindSeg’: chipmunk/cpCollision.c:233:0: warning: cast from pointer to integer of different size chipmunk/cpCollision.c: In function ‘seg2poly’: chipmunk/cpCollision.c:274:0: warning: cast from pointer to integer of different size chipmunk/cpCollision.c:276:0: warning: cast from pointer to integer of different size chipmunk/cpSpace.c: In function ‘queryFunc’: chipmunk/cpSpace.c:411:0: warning: cast from pointer to integer of different size chipmunk/cpSpace.c:411:0: warning: cast from pointer to integer of different size This can't be correct, but I'll probably have to take a look at that. Or is it a know bug that Hipmunk ist not 64bit-clean? Cheers, S.

On Sun, May 03, 2009 at 02:07:23PM +0200, Sven Panne wrote:
As a side note, I get a very bad feeling when Hipmunk gets compiled on my x86_64 box: [...] This can't be correct, but I'll probably have to take a look at that. Or is it a know bug that Hipmunk ist not 64bit-clean?
My machine is actually a x86_64, and I don't like those warnings as well :). Yes, it is a know bug in Chipmunk, but maybe it got corrected. One small problem with Chipmunk is that it is a moving target, so updating Hipmunk's Chipmunk library would require changing the bindings as well (AFAIK at least the joints code would have to be rewritten), and I don't know if there is a changelog specifying the changes (i.e. "read the diff" :). -- Felipe.

I noticed that Chipmunk also has a Ruby interface. Do you have any pro/con
of implementing the game in Ruby vs Haskell?
Thanks,
Daryoush
On Sat, May 2, 2009 at 12:00 PM, Duane Johnson
Reprinted from my blog post [1]:
===
The semester is over, my final project was a success (at least in that I passed the class) and it’s time now to release the game I made for Graphics 455: Silkworm!
This is my first full application in Haskell. The process has been an enlarging experience–I’ve come to really enjoy the mental work that goes into thinking about a program in a functional way. I highly recommend the challenge to other software engineers.
Silkworm combines the Hipmunk binding to Chipmunk 2D Game Dynamics with OpenGL, and GLFW (an alternative to GLUT).
It’s built to work on Mac OS X, but it uses cross-platform libraries so it should be fairly easy to port to other platforms. The source code is here [2] and below are some screenshots [1]
-- Duane Johnson (canadaduane)
===
[1] http://blog.inquirylabs.com/2009/05/02/silkworm-game-written-in-haskell/ [2] http://inquirylabs.com/downloads/Silkworm.tgz_______________________________... Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
/

I'm not too much of an expert in Haskell, but I did notice that building the game required keeping track of a lot of state information, which was not very intuitive in Haskell (although the OpenGL state info is rather intuitive). If I were to do it in Haskell again, I would try to learn more about FRP (Functional Reactive Programming) and see if that improves things in terms of state. Ruby is my favorite imperative language, so I would certainly recommend it for game development. It would likely be much easier in Ruby, but perhaps a little slower. My experience with Ruby on Rails has been that it is always a little slower than I wish it were :) -- Duane On May 3, 2009, at 4:48 PM, Daryoush Mehrtash wrote:
I noticed that Chipmunk also has a Ruby interface. Do you have any pro/con of implementing the game in Ruby vs Haskell?
Thanks,
Daryoush
On Sat, May 2, 2009 at 12:00 PM, Duane Johnson
wrote: Reprinted from my blog post [1]:
===
The semester is over, my final project was a success (at least in that I passed the class) and it’s time now to release the game I made for Graphics 455: Silkworm!
This is my first full application in Haskell. The process has been an enlarging experience–I’ve come to really enjoy the mental work that goes into thinking about a program in a functional way. I highly recommend the challenge to other software engineers.
Silkworm combines the Hipmunk binding to Chipmunk 2D Game Dynamics with OpenGL, and GLFW (an alternative to GLUT).
It’s built to work on Mac OS X, but it uses cross-platform libraries so it should be fairly easy to port to other platforms. The source code is here [2] and below are some screenshots [1]
-- Duane Johnson (canadaduane)
===
[1] http://blog.inquirylabs.com/2009/05/02/silkworm-game-written-in-haskell/ [2] http://inquirylabs.com/downloads/Silkworm.tgz_______________________________... Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
/
participants (6)
-
Daryoush Mehrtash
-
Don Stewart
-
Duane Johnson
-
Felipe Lessa
-
Peter Verswyvelen
-
Sven Panne