6909ea5d4e
That was specific to exo-encounter and is unlikely to be useful in other games. |
||
---|---|---|
appimage | ||
lib | ||
.gitignore | ||
changelog.org | ||
conf.lua | ||
license.txt | ||
love-release.sh | ||
main.lua | ||
makefile | ||
mode-intro.fnl | ||
readme.org | ||
wrap.fnl |
Minimal Fennel Love2D Setup
In a lead up to the annual Autumn Lisp Game Jam I thought I'd look into Phil Hegelberg's approach to last Aprils Jam, using love2d in concert with fennel. Phil outlines his approach on his blog.
The first step is to see how fennel works as a standalone execution environment, then slowly integrate some of the love2d API.
This repo contains the minimal viable setup to get started with Phil Hegelberg's game design process, plus some additional libraries.
Phil's Modal Callbacks (PMC)
Phil Hegelberg's exo-encounter-667 is structured using a modal callback system. Each game state has a mode and each mode has a series of specific callbacks.
If you design your game as a series of states in a very simple state machine, for example start-screen, play and end, with unidirectional progression, you can easily separate the logic for each state into state/mode specific callbacks. As an example, in order to have state dependant rendering that differs between start-screen,play and end you could provide a draw callback for each of those states. Similarly if we need state dependent logic and keyboard input we could provide update and keyboard callbacks. As you iterate you can add and remove callbacks and states/modes as needed with very little friction.
Emacs Setup
(autoload 'fennel-mode "/path/to/fennel-mode" nil t)
(require 'fennel-mode)
;; By default fennel-mode moves focus to the \*inferior-lisp\* buffer
;; setting `fennel-mode-switch-to-repl-after-reload' to nil prevents this
(customize-save-variable 'fennel-mode-switch-to-repl-after-reload nil)
(add-to-list 'auto-mode-alist '("\\.fnl\\'" . fennel-mode))
;; you can bind this to whatever you like
(defun run-love ()
(interactive)
(run-lisp "love ."))
;; for some reason when I load a fnl file it starts the slime minor mode
;; I have included the hook below to prevent this
(defun fennel-mode-hook-fun ()
(interactive)
(slime-mode nil))
(add-hook 'fennel-mode-hook 'fennel-mode-hook-fun)