A simple Asteroids clone, inspired by Square Shooter by No Time To Play, but written in Common Lisp with Lispbuilder-SDL.
I'm learning Common Lisp this year, and it seemed like a fun project. It was.
Wow, I made the front page of Hacker News!
I read a few questions there and on /r/programming about why I did this, and it really was just a fun learning project, partly in response to an article I read about refactoring the original Python version.
Thanks to everyone for the generally positive feedback!
I wasn't trying to fit it into 600 LOC or trying to make a very clean or fast implementation.
The code is quite un-Lispy because I'm only about 4 months into learning Lisp and this is a translation from a Python codebase, rather than starting from scratch. I also wanted to learn a bit of CLOS. I haven't really tried any macro programming yet.
I did write it using Vim, because that's what I'm used to, and I haven't got into Emacs and Slime yet. It's difficult to switch, but I will give it a try.
There aren't many inline comments, I'm not a fan of them. I prefer my code to be self documenting as far as possible.
It's a pun on Abstract Syntax Tree - which Lisp essentially is. Sorry.
I've also tested with Clozure CL.
I used Homebrew to install SDL and SDL_gfx on my Mac.
Start SBCL and type the following at the REPL prompt:
(sb-ext::set-floating-point-modes :traps nil) (load "asteroids.lisp")
Quicklisp will then install some dependencies. When Quicklisp tries to install Lispbuilder-SDL, it may fail and complain about CocoaBuilder. You have to manually compile it:
cd ~/quicklisp/dists/quicklisp/software/lispbuilder-20130312-svn/lispbuilder-sdl/cocoahelper make
Then retry loading asteroids.lisp
Once that is done, you can start the game from the REPL with:
The game is mouse controlled.
A bit rubbish, really. Next steps are learning some OpenGL to make it a bit prettier.