massung / r-cade

Retro Game Engine for Racket
https://r-cade.io
Other
273 stars 13 forks source link

example games don't all run #24

Closed wu-lee closed 3 years ago

wu-lee commented 4 years ago

I spotted the programs in the examples/ directory and wanted to try them out. This works:

cd examples
racket columns.rkt

This doesn't:

racket defender.rkt

It simply outputs:

AL lib: (EE) alc_cleanup: 1 device not closed

...And halts. Googling, I gather that message is harmless, but why doesn't anything happen?

This is the case for most of the examples. Only columns and invaders work...

Possibly I missed something in the documentation, but so far I can't see anything which mentions anything special about how these examples should be run.

Inspecting the code, the answer is apparently trivial - those games which work, invoke run, and those which don't, wrap it in a function play (which doesn't get invoked).

This seems surprisingly obvious, so I'd like to check I'm not missing something before trying to patch this?

p.s. Thanks for writing this, it seems exactly what I was looking for as a platform to (maybe) get my children interested in programming.

massung commented 4 years ago

Ok. I wrote (most of) the examples assuming they'd be loaded/run from DrRacket and that users would want to call play themselves so they could inspect data, etc. before doing so. Modifying them to add the call automatically would - of course - be trivial. Let me think about whether there would be any downsides to doing so.

Regarding the "AL lib" issue, I've never seen that. It's OpenAL. Are you sure you have the latest version of it installed for your platform (also, which platform would that be)?

wu-lee commented 4 years ago

Either way is fine; a short README in the directory could point people like me in the right direction.

Perhaps you could get the best of both worlds using a pattern like this:

http://reference-error.org/2014/02/24/loading-main-function-in-racket.html

i.e. Append this:

(module+ main
  (play))

Then it seems to work to run it as I did.

wu-lee commented 4 years ago

Just to add, regarding the "AL lib" warning...

I'm running Racket v7.6 on Ubuntu 19.10 (Focal Fossa), with the package libopenal1:amd64 version 1:1.19.1-1.

I ran into the CSFML packaging bug mentioned in #5, and have rebuilt a libcsfml package using the procedure I described on that issue. So I have SFML 2.5.1 and CSFML 2.5.

massung commented 4 years ago

Version 0.4.0 adds the module+ main to all the examples. Thanks for that.