Cool to see clojure running in godot!
Alex βπ¨π¦
Creator of
Recent community posts
The Autumn lisp game jam is almost upon us! Today, its wonderful to see so many lisp dialects and a game frameworks available to use to make games :) This is a far cry from the first jam in 2016.
As always, I am here to evangelize making games with Fennel, a lispy lua, and Love 2d.
I was inspired to start making games with Fennel and Love after reading @technomancyβs 2018 exo encounter devlog, which outlined how to get up and running developing a game interactively with Fennel. If youβd like get started check out the βminimalβ love2d fennel template.
The template provides a repl you can use to modify your running environment, and hotload modules that have been modified. Note, careful state management is required when hotloading. Make sure any state you wish to persist is stored outside of the module you are reloading. Feel free to reach out it you have any questions about setting up your game to work interactively.
If youβre just getting started with fennel, but are familiar with lua, the fennel reference is a great place to start. Even if youβre not familiar with lua, (I wasnβt when I started) the language is concise enough to pick up in a weekend! There are also a collection of example codebases to help you get started.
Love 2d is a great framework to get started in. The wiki provides lots of useful examples to get you started, and there are numerous libraries available to help with the game dev process. Some of my favorites are bump, anim8, gamestate and lume.
If youβre brave you can also try targeting the web. The βminimalβ love2d fennel template has a βwebβ target that may be used in the makefile. Note that desktop love 2d relies on luajit. The core of luajit is assembly, which cannot be ported through emscripted to the web. Instead we rely on Lua PUC 5.1, which has some subtle but significant differences in behavior. There are numerous other small gatchas when porting to the web. Make sure you load assets statically rather than streaming them, and avoid the use of threads.
If youβd like to do web first development to avoid fixing these gatchas at the last minute check out the fennel lovejs template. This template has built in support for using both Lua5.1 and Lua5.4 (Iβd recommend using Lua 5.4). It lets you both build a single html file that may be hosted and to run a shell/repl so you can interactively modify your running game. It also incorporates a Linux build of Love2d compiled to work with Lua 5.4 that can be used for local testing and for desktop distribution.
Here is a small snippet to show how easy it is to get up and running with love2d and fennel. Happy Jamming!
(var time 0)
(local display-string "Time since last click: %d")
(local font (love.graphics.newFont 30))
(fn love.update [dt]
(set time (+ time dt)))
(fn love.draw []
(love.graphics.setFont font)
(love.graphics.print (display-string:format time) 10 10))
(fn love.mousepressed [_button _x y]
(set time 0))
Thanks for trying it out <3
Iβve got a bug patch ready to go for next week. Iβll look into the issue of people outside of vehicles consuming fuel.
Each person / vehicle has a carry limit for consumables. Getting into a car or truck will let you carry more / use more of the pickups. Outside of a car your avatar can only carry 5 of each.
There was a bug in the web version that prevented you from fixing the vehicles without getting into them first. You should have all the resources you need at your starting outpost to fix up the closest car.
Edit: Found the bug causing fuel consumption it will be addressed in the new patch
Fennel is a clojure styled lisp that transpiles to Lua. Love2d is one of the easiest game frameworks to get started with.
min-love2d-fennel is all you need to get started writing love2d games with fennel. These days the name is a bit of a misnomer, the template comes with builtin tools to manage game modes, a fennel repl and buildtools required to compile a love2d game for Windows, Mac, Linux and HTML5.
Setup
You can always clone min-love2d-fennel and go from there, but an easier way is to use the new fennel-deps tool by @andreyorst.
Simply clone the fennel-deps repo, and run
deps --new io.gitlab.alexjgriffith/min-love2d-fennel my-awesome-game
To get started with fennel on emacs check out fennel-mode. To make working with love2d and fennel easier check out love2d-fennel.el.
The Basics
If you want to start with the most bare bones setup you can delete everything in the template, apart from main.lua and conf.lua. You can then start playing around with the love2d framework in wrap.fnl. The examples below have been taken from the love2d landing page.
Drawing Text
(fn love.draw []
(love.graphics.print "Hello World!" 400 300))
Drawing and Image
(local images {})
(fn love.load []
(tset images :whale (love.graphics.newImage "whale.png")))
(fn love.draw []
(love.graphics.draw images.whale 300 300)
Playing a Sound
(fn love.load []
(let [sound (love.audio.newSource :music.ogg :stream)]
(love.audio.play sound)))
Template Features
The entry point for your fennel code is in wrap.fnl. This module wraps the draw, update and keypressed callbacks of love2d in a way that prevents your project from hard crashing if you make a simple error during development.
Game specific code can be found in the module mode-intro. You can modify mode-intro to suit the needs of your game, or you can write your own modes. wrap.fnl expects mode modules to return a table containing the callbacks activate, draw, update and keypressed.
- The
drawcallback takes no arguments. - The
activatecallbacks takes no fixed arguments. Any arguments passed toset-modeare received by this callback. - The
keypressedcallback takes the key pressed and theset-modefunction as its arguments. - The
updatecallback takes dt (delta time) and theset-modefunction as its arguments.
In either keypressed or update you can call set-mode to change the currently running mode.
Example
Below is a simple hello world game made using the template.
Replace mode-intro with mode-game in wrap.fnl.
;; mode-game.fnl
(local fennel (require :lib.fennel))
(fn pp [x] (print (fennel.view x)))
(var message "")
(fn activate []
(pp "Loading mode :mode-game")
(set message "Hello World!!")
;; load any assets you need for this mode here
)
(fn draw []
(love.graphics.print message 300 200))
(fn update [dt set-mode])
(fn keypressed [key set-mode])
{: activate : draw : update : keypressed}
To launch your game either run love . in the command line in the directory with your game or use the command C-c C-z if you are using emacs and youβve setup fennel-mode and love2d-fennel.el.
Building Your Game
If you want to release your game on Windows, Mac or Linux you can use the provided makefile. Replace the header information in makefile and the titles in conf.lua with the information for your game.
You can make individual builds by running make linux, make mac, make windows and make web. Note for the web we target Lua PUC 5.1 rather than luajit, so if you want your games to run on the web use the subset of lua that is compatable with both Lua PUC 5.1 and luajit.
If you want to release your game on itch.io the makefile also provides the command make release, which will use butler to upload your game to itch.io.






















