Find a file
Alexander Griffith 67ca04f967 Merge branch 'macOS-gdu' into 'master'
Use gdu on macOS

See merge request alexjgriffith/min-love2d-fennel!14
2022-03-25 23:44:37 +00:00
.duplicate implemented duplicate 2022-03-25 19:40:58 -04:00
buildtools Use gdu on macOS 2022-03-23 21:48:14 -05:00
lib Bump Fennel version to 1.0.0 2022-03-24 00:30:47 -05:00
.gitignore Switched over from using the .tar.gz artifact to the AppData artifact for linux builds for 11.4 compatibility 2022-03-16 17:38:45 -04:00
conf.lua Updated makefile and conf to default to love 11.4 2022-03-16 20:22:07 -04:00
error-mode.fnl Wrap mode handlers in xpcall+error-mode. 2021-09-11 19:33:56 -07:00
license.txt Initial commit. 2018-10-17 21:32:39 -04:00
main.lua Implemented macro loader. Updated Makefile. Closes #5 2021-09-13 01:25:46 -04:00
makefile Updated makefile and conf to default to love 11.4 2022-03-16 20:22:07 -04:00
mode-intro.fnl Updated makefile and conf to default to love 11.4 2022-03-16 20:22:07 -04:00
readme.org implemented duplicate 2022-03-25 19:40:58 -04:00
sample-macros.fnl Introduced sample-macros.fnl to demonstrate how import-macros works. 2021-09-14 01:11:55 -04:00
wrap.fnl Updated makefile and buildtools to work with web 2021-09-13 01:15:26 -04:00

Minimal Fennel Love2D Setup

In the lead up to the semi-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.

This repo contains the minimal viable setup to get started with Phil Hegelberg's game design process, plus some additional libraries.

Getting Started

The following commands will clone this project and duplicate its structure into a new folder $PROJECT_NAME

git clone https://gitlab.com/alexjgriffith/min-love2d-fennel.git 
./min-love2d-fennel/.duplicate/new-game.sh $PROJECT_NAME

Check out the makefile and conf.lua files in $PROJECT_NAME, updating them with information relevant to your game.

You can enter love . in the $PROJECT_NAME directory to run your game, or make run.

The following lines with Update should be changed in the makefile and love.conf to reflect your game.

VERSION=0.1.0
LOVE_VERSION=11.4
NAME=change-me # Update
ITCH_ACCOUNT=change-me-too # Update
URL=https://gitlab.com/alexjgriffith/min-love2d-fennel # Update
AUTHOR="Your Name" # Update
DESCRIPTION="Minimal setup for trying out Phil Hagelberg's fennel/love game design process." # Update
love.conf = function(t)
   t.gammacorrect = true
   t.title, t.identity = "change-me", "Minimal" -- Update
   t.modules.joystick = false
   t.modules.physics = false
   t.window.width = 720
   t.window.height = 450
   t.window.vsync = false
   t.version = "11.4"
end

Emacs Setup

Once you install the latest version of fennel-mode, you can run C-u M-x fennel-repl followed by love . to launch a repl.

Default Project Structure

The make process as-is will only compile the contents of the root folder and the lib/ folder+subfolders, so make sure to put your game files in either of those.

Specifically, every .fnl file needed at runtime needs to be situated in the root folder, and every file which is not a .lua or .fnl file needs to be put inside lib/.

In order to use macros, they have to be put in .fnl files inside lib/.

Seperate your Code into a /src directory

If you want a more opinionated layout, you can use pass in a --layout parameter when creating your project.

./min-love2d-fennel/.duplicate/new-game.sh $PROJECT_NAME --layout=seperate-source

This build uses gamestate rather than Phil's approach to scene seperation and puts all your .fnl files into a /src directory. It also provides a seperate makefile that handles this layout.

Note, any macros will have to be placed in the root of the project or in the lib folder (this can be modified in main.lua)

Presently the only layouts are clone and seperate-source. If you want to make your own check out the .duplicate directory to see how they work.

Release Process

Use make linux, make windows, make mac, or make web to create targets for each platform, or make release to make all four. Check out the makefile for more commands, and remember to edit your game data in it!

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.