Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Template for a browser game (Fennel + TIC-80)

A topic by Stefan Devai created Apr 09, 2020 Views: 597 Replies: 6
Viewing posts 1 to 3
Submitted(+2)

Hi everyone! :)

If you're planning to create a simple game that's playable in the browser, I created a simple template with boilerplate code and a util script for development. You can get the code on GitHub.

It uses Fennel (a lisp that compiles to Lua), and TIC-80 a fantasy computer that can compile to WASM and WebGL. Apparently, this stack has been widely used in past lisp jams.

Here is a Fennel tutorial, and here some TIC-80 tutorials.

Submitted

This is cool; thanks.

One thing I might suggest having done a TIC game for a jam before is to avoid splitting it into separate source files, because that makes it so that the line numbers are incorrect. It’s a bit nicer for organization but a lot more confusing for debugging, so I wished that I hadn’t done it for my game.

Submitted

Hi, thanks for your comment! :)

You're right, debugging script languages is generally hard. But the bash script I wrote already appends each source file to a single fennel file (build/out.fnl). So then we compile only this file and the line numbers shown by the compiler can be easily checked there. Or how were you compiling multiple files in your game? Were you doing the same thing and it was still hard to debug?

Submitted

Yeah, this is what I did for my game last year. Whenever you get an error you have to look at the combined output to figure out which function it happened in, then try to correlate that to which file in the split files contains that function. I found that this was a bit of a headache once we got to over a thousand lines, and I wished that we had just used a single file for the whole thing. In most Fennel projects you can use the module system to split up the files, but TIC doesn’t let you do that for minimalism reasons.

Also one other gotcha is that the latest master version of TIC uses Fennel 0.3.0 while the stable builds use Fennel 0.1.0, so unless you build from source, you won’t have access to the latest Fennel features; this could be potentially rather confusing. The documentation from here may be useful: https://fennel-lang.org/v0.1.0/

Submitted

I see! Thanks a lot for both suggestions, they'll be helpful :) I'll include them in the README. If you remember any other problem you had when developing with this stack, feel free to submit a PR.

Submitted

About the problem you mention with last fennel version supported by TIC, I'm actually compiling the fennel code to Lua before loading it with TIC. So I expect no problem related to versions.

Submitted(+1)

Ah, yes I see how that would simplify things. I thought about doing this, but I figured it would be a shame if people couldn’t press ESC to see the real code behind the game within TIC after they finished playing to hack around with it. But it does let you use the features from the newest version without any hassle.