Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Video game graphics in Common Lisp

179 views
Skip to first unread message

Don Geddis

unread,
Sep 17, 2011, 11:41:56 AM9/17/11
to
Any recommendations for a library to write a 2D graphics game in Common
Lisp?

Imagine you wanted to write Pong or Asteroids or Centipede, with the
logic being in Common Lisp. (Best if it would work on some open source
CL platform.)

I'm guessing the operating systems have built-in graphics libraries, and
mostly what one uses is bindings into the OS. Ideally I'd like to
develop under linux, and perhaps deploy on windows, but maybe that's
asking too much, as there is little in common between linux and windows.

Anyone have experience in this, and any advice to offer me?

Thanks,

-- Don
_______________________________________________________________________________
Don Geddis http://don.geddis.org/ d...@geddis.org
Q. How do you attract a vegetarian?
A. Make a noise like a wounded vegetable.

Zach Beane

unread,
Sep 17, 2011, 12:42:33 PM9/17/11
to
Don Geddis <d...@geddis.org> writes:

> Any recommendations for a library to write a 2D graphics game in Common
> Lisp?
>
> Imagine you wanted to write Pong or Asteroids or Centipede, with the
> logic being in Common Lisp. (Best if it would work on some open source
> CL platform.)
>
> I'm guessing the operating systems have built-in graphics libraries, and
> mostly what one uses is bindings into the OS. Ideally I'd like to
> develop under linux, and perhaps deploy on windows, but maybe that's
> asking too much, as there is little in common between linux and windows.
>
> Anyone have experience in this, and any advice to offer me?

I've heard good things about lispbuilder-sdl for this type of stuff.

Zach

adeht

unread,
Sep 17, 2011, 6:56:09 PM9/17/11
to
Don Geddis <d...@geddis.org> writes:

> Any recommendations for a library to write a 2D graphics game in Common
> Lisp?

You may find this link useful: http://lispgames.org/

I found cl-opengl sufficient for my needs:

https://github.com/death/towers
https://github.com/death/consix

Bakul Shah

unread,
Sep 17, 2011, 9:36:39 PM9/17/11
to
On 9/17/11 8:41 AM, Don Geddis wrote:
> Any recommendations for a library to write a 2D graphics game in Common
> Lisp?
>
> Imagine you wanted to write Pong or Asteroids or Centipede, with the
> logic being in Common Lisp. (Best if it would work on some open source
> CL platform.)
>
> I'm guessing the operating systems have built-in graphics libraries, and
> mostly what one uses is bindings into the OS. Ideally I'd like to
> develop under linux, and perhaps deploy on windows, but maybe that's
> asking too much, as there is little in common between linux and windows.
>
> Anyone have experience in this, and any advice to offer me?

If Scheme will do, give Ypsilon scheme a try. Uses openGL,
works on FreeBSD, OS X, Linux, and Windows. IIRC it has a
decent FFI. It is quite fast and uses a mostly concurrent GC
to minimize GC pauses since the author developed it to be used
in a real time game. And check out author's gorgeous 3D
pinball games (its rules are described in a DSL in Scheme).

http://www.littlewingpinball.com/doc/en/ypsilon/index.html

Andrea D'Amore

unread,
Sep 18, 2011, 3:42:54 AM9/18/11
to
In article <4E754B27...@bitblocks.com>,
Bakul Shah <use...@bitblocks.com> wrote:

> And check out author's gorgeous 3D
> pinball games (its rules are described in a DSL in Scheme).

Wow, "Tristan Pinball" I _loved_ that game back then on System. Thanks
for pointing that out.

A.L.

unread,
Sep 18, 2011, 12:02:38 PM9/18/11
to
On Sat, 17 Sep 2011 08:41:56 -0700, Don Geddis <d...@geddis.org> wrote:

>Any recommendations for a library to write a 2D graphics game in Common
>Lisp?
>
>Imagine you wanted to write Pong or Asteroids or Centipede, with the
>logic being in Common Lisp. (Best if it would work on some open source
>CL platform.)
>
>I'm guessing the operating systems have built-in graphics libraries, and
>mostly what one uses is bindings into the OS. Ideally I'd like to
>develop under linux, and perhaps deploy on windows, but maybe that's
>asking too much, as there is little in common between linux and windows.
>
>Anyone have experience in this, and any advice to offer me?


Switch to Java, C#, Python etc. Save time and energy.

A.L.

Tim Bradshaw

unread,
Sep 18, 2011, 12:23:52 PM9/18/11
to
On 2011-09-18 17:02:38 +0100, A.L. said:

> Switch to Java, C#, Python etc. Save time and energy.

Also, it's easier on a BBC micro.

Peter Keller

unread,
Sep 19, 2011, 2:20:59 AM9/19/11
to
Hello,

Don Geddis <d...@geddis.org> wrote:
> Any recommendations for a library to write a 2D graphics game in Common
> Lisp?
>
> Imagine you wanted to write Pong or Asteroids or Centipede, with the
> logic being in Common Lisp. (Best if it would work on some open source
> CL platform.)
>
> I'm guessing the operating systems have built-in graphics libraries, and
> mostly what one uses is bindings into the OS. Ideally I'd like to
> develop under linux, and perhaps deploy on windows, but maybe that's
> asking too much, as there is little in common between linux and windows.
>
> Anyone have experience in this, and any advice to offer me?

I wrote a small game using Common Lisp a bit ago. I used
lispbuilder-sdl and cl-opengl as my main libraries. They worked
out excellently.

Generally, I'd use lispbuilder-sdl to open the display, run the
physics engine, deal with assets (like texture images), and handle
keyboard/mouse inputs. I'd use cl-opengl for the actual drawing. You
can load a png with lispbuilder-sdl and put it into a sdl buffer
suitable for binding to cl-opengl. This is good enough for a lot
of needs. lispbuilder-sdl has excellent, if almost too verbose,
documentation and cl-opengl, well, isn't so well documented but after
reading of shipped example code and other stuff you'll figure it out.

I'm not saying what I wrote is good code (though a number of people
here helped me write much more idiomatic CLOS), but here's an example
of what I did (though it used line graphics, and not 2d sprites,
but it was 2D).

http://pages.cs.wisc.edu/~psilord/lisp-public/option-9.html

The entirety of the code is explained. The main interest for you
is probably near the bottom of the document, where it shows how to
use lispbuilder-sdl.

Even tough I wrote it for SBCL on linux, a friend got it working
with a _tiny_ patch (that the current sources has and it turned out
to be some nonconforming code that SBCL accepted silently) with CCL
on windows. I was surprised. :) This tells me that as long as you
stick to libraries which exist across linux and windows in Common
Lisp along with as much ANSI stuff as you can, you can have your
portability without too much trouble.

I'm writing another game where I discovered that lispbuilder-sdl and
cl-gtk2 just don't mix very well (and lo, I was sad). I'd avoid using
those at the same time. cl-gtk2 and cl-opengl together will work, but
there is a funny thing about cl-gtkglext (which enables embedding of
an opengl context into a gtk window) and that might not be portable...

I haven't yet explored GPU programming with Common Lisp yet, but I'll
get there...

I hope you find this stuff helpful.

Later,
-pete

Don Geddis

unread,
Sep 19, 2011, 11:58:21 PM9/19/11
to
Wow! Not just a library, but working example code too. VERY helpful.

Took me about 1/2 an hour, on a vanilla Ubuntu installation. I
downloaded your code, and SBCL. Your code mentioned needing some
libraries. Many of them (e.g. cl-cffi, cl-alexandria) were already
packaged up on Ubuntu, so those were easy to install. I got a little
stuck with cl-opengl, which was not (as far as I could tell) already
available as a Ubuntu package. I tried downloading the source, but it
didn't compile completely.

Then it occurred to me to attempt it indirectly. I installed quicklisp
instead, and then used that to install cl-opengl. And presto! Your
games actually ran on my desktop!

Much appreciated. Being able to start with a useful, working program is
SO much easier than trying to build something from scratch (even with a
library).

-- Don

BTW: I tried to send you email, but "nessers.com" bounced for me. Would
you mind emailing me when you get a chance?

Don Geddis

unread,
Sep 20, 2011, 12:01:36 AM9/20/11
to
Peter Keller <psi...@cs.wisc.edu> wrote on Mon, 19 Sep 2011:
> Don Geddis <d...@geddis.org> wrote:
>> Any recommendations for a library to write a 2D graphics game in Common
>> Lisp?
>
> I wrote a small game using Common Lisp a bit ago. I used
> lispbuilder-sdl and cl-opengl as my main libraries. They worked out
> excellently.
> http://pages.cs.wisc.edu/~psilord/lisp-public/option-9.html

Fabulous. I managed to download, install, and run it under Ubuntu
linux, using SBCL. (Used quicklisp to get lispbuilder-sdl and
cl-opengl.)

Seems to run fine! I very much appreciate you offering working game
code as a teaching tool for me.

-- Don
_______________________________________________________________________________
Don Geddis http://don.geddis.org/ d...@geddis.org
[Wolfram Alpha's UI] achieves the coveted status of a non-solution to a
non-problem. -- Mencius Moldbug
0 new messages