[Haskell-cafe] 2D game graphics library for Haskell?
duncan.coutts at worc.ox.ac.uk
Thu Aug 30 09:45:25 EDT 2007
On Fri, 2007-08-24 at 12:31 +0200, peterv wrote:
> Anyway, SOE is great for learning Haskell, but it lacks a couple of
> fundamental functions to make it really attractive, like:
> - Support for images
> - Support for rendering to an “offscreen graphics surface” and
> reading the pixels from that surface (for pixel-wise collision
> - Support for detecting non-ASCII key presses (cursor keys, etc)
> - Support for joysticks
> Concurrent Clean seems to have a nice 2D game library and PLT/DrScheme
> also has nice support for basic 2D graphics, but somehow I feel
> Haskell is more mature and more elegant.
> So before digging into “advanced” APIs (like GTK itself, which I know
> nothing about, I’m a Win32 GDI/XNA/WPF expert), I should ask the
> question if something similar exists? It has to be as simple as SOE.
Would it be possible to extend the GTK SOE with support for the features
mentioned above? Is this insanely difficult for someone like me who
knows a lot about Win32 but little Haskell?
Graphics.SOE.Gtk is actually based on a very nice vector graphics
library Graphics.Rendering.Cairo which can certainly do nice things like
rendering to off-screen surfaces and much more besides, like
transparency, arbitrary affine scaling/rotation/translation. It can load
and save images in png and svg formats. It's also got a rather nice API,
so instead of trying to extend the GTK SOE you might find it simpler
just to use Cairo directly.
Gtk+'s event processing can certainly detect non-ASCII key presses, it's
just the SOE getKey api that's limited to Char. I've no idea how
joystick input is implemented in X/Gtk, I expect it's possible.
The other alternative though it's getting more low level, is to use the
Haskell bindings for SDL.
More information about the Haskell-Cafe