What I found most interesting however, was his interactive programming setup.
With Emacs and some Lua thread magic, he was able to perform runtime changes and introspection to his live running game project. (See below for a demo!)
Based on past experience developing visualization and image processing algorithms, I learned how useful this sort of interactive / runtime programming could be.
Hagelberg wrote up his experience in three great blog posts:
- in which a game jam is recounted
- in which a game jam is recounted further
- in which interactive development saves the day
… and he has made the full source code to EXO_encounter 667 available on gitlab, so I had to try the interactive programming setup out for myself.
Due to his great write-ups, this was surprisingly easy.
Below you’ll find a short screencast of the setup in action, the steps I took to get everything running, and finally some information on how he put the interactive programming parts of the game together.
Here is a short video demonstrating a live programming session:
Here are the steps I followed to get everything up and running:
Install löve, lua and fennel
brew install caskroom/cask/love brew install lua luarocks install --server=http://luarocks.org/dev fennel
Install the Emacs fennel-mode
This important piece of code is also by Hagelberg.
fennel-mode where you usually work with github and gitlab checkouts:
mkdir ~/build && cd ~/build git clone https://gitlab.com/technomancy/fennel-mode.git
Evaluate the following two lines in Emacs using for example
(autoload 'fennel-mode (expand-file-name "~/build/fennel-mode/fennel-mode") nil t) (add-to-list 'auto-mode-alist '("\\.fnl\\'" . fennel-mode))
Get and start playing with EXO_encounter 667
git clone https://gitlab.com/technomancy/exo-encounter-667.git
Start by opening
wrap.fnl in the root directory.
Then, as per the instructions, start the Fennel repl using
C-u M-x run-lisp. This will ask you which lisp to use. Replace the default
fennel --repl with
love . (that’s
love followed by space and a period)
At this point you will get a repl via which you can enter fennel commands. You can also edit any of the top-level fennel files, and type
C-c C-k to reload the whole file, and watch the game change before your eyes.
More detail on how the interactive programming parts work
When you start
love . from within Emacs fennel-mode, this runs the game, but starts an extra Lua thread to listen for input from Emacs.
(see the Interactive Development section in the blog post titled “in which a game jam is recounted further“)
love.load, it starts the repl, which is loaded from lib.stdio, which is where the extra listener thread is started up.
fennel-mode does the rest. Once you’ve done
love ., you can use all the dynamic commands described on the fennel-mode gitlab page.