Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Asteroids game in Common Lisp
Common Lisp
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
README.mdown Link to homebrew
asteroids.lisp Let the method signature specify the parameter type, instead of using…

README.mdown

ASTeroids

A simple Asteroids clone, inspired by Square Shooter by No Time To Play, but written in Common Lisp with Lispbuilder-SDL.

Why?

I'm learning Common Lisp this year, and it seemed like a fun project. It was.

UPDATE

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.

Why are the first three letters of ASTeroids capitalized?

It's a pun on Abstract Syntax Tree - which Lisp essentially is. Sorry.

How do I play it?

You'll need to install Steel Bank Common Lisp and the Quicklisp package tool, which is pretty easy.

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:

(asteroids:main)

The game is mouse controlled.

What does it look like?

A bit rubbish, really. Next steps are learning some OpenGL to make it a bit prettier.

ASTeroids screenshot

Something went wrong with that request. Please try again.