FunSpIns - a recap of Rob Ashton's lessons - Das Intro

17 Sep 2013 in software-development | haskell | fun-spin |

Functional space-invaders series

  1. A recap of Rob Ashton’s lessons - Das Intro
  2. Drawing a Rectangle
  3. Moving a Rectangle
  4. No attributes, No vectors, A tiny Workflow and more squares
  5. State, the World, the Loop
  6. The hero must move, the enemies must move smarter
  7. The hero shoots
  8. Collisions, the dead, and a (not so) grateful ending

A few weeks ago I was considering following Rob Ashton’s footsteps in learning functional programming by programming a game (Space Invaders, or Functional Space Invaders or FunSpIns, right? le sigh) However, since I am currently digging deeper into Haskell, that would obviously become my weapon of choice. Looking at possibilities to get Haskell somehow produce something that would do something against an HTML Canvas led me to the Haskell to JavaScript compiler. However, the easy path stated that it would ideally need the GHC version 7.8. Let’s have a look at my version…

My version

So I would be leaving Haskell mainstream. A bit much, and I laid the case to rest, even though the idea is not as absurd as you may think. Then I heard that a Version 2.0 of a libsdl would be coming out, apparently a full blown library to support game development on a number of platforms, and that Haskellians could now update their bindings. Then I also came across a guy who had done a whole series on programming a game with haskell and SDL, (Simple DirectMedia Layer).

Surely, I felt safe enough to get on with the idea, now that I would be able to concentrate on the programming and less on the fringes of getting xyz to run in context a. Yes, I also shower with warm water and prefer to smoke Cohibas. And yes, of course I am not the first guy to use SDL with Haskell, and not the second guy either. Either way, using a different rendering target than envisaged would be a nice motivator to try and get the game logic separated from the rendering. For potential future portability. You know, theoretically speaking.

The necessary incantations, provided you already have Haskell on your Linux, are

sudo apt-get update
sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev
cabal update
cabal install SDL
cabal install SDL-image

(cabal is Haskell’s package manager)

And with that, we are pretty much ready to tackle the stuff that comes…

Disclaimer

I am a functional programming noob. I may be more successful at doing a GUI interface using visual basic to track the killers IP address. I have years of imperative languages under my belt, and while we all know what delegates are, that LINQ are actually operations in the monad of Enumeration, that F# preferred to call them computational expressions, and how functional Javascript is, this Haskell stuff, even though it sometimes looks eerily imperative, has completely different underpinnings in terms of theory, philosophy and utter spoon bending, so bear with me.

Chronology

  |  
comments powered by Disqus