Using game libraries with Hoot like Phaser or Three.js

Hello!
For the upcoming Hoot game jam, It would be nice to be able to use rendering libraries for the web like Phaser or Three.js or whatever. How would that work?

Complexity will vary depending on the library but the process is the same. Use (hoot ffi) to define the necessary interface and write the relevant JS functions to be used as imports when you call Scheme.load_main to instantiate the Wasm binary.

For example, here’s how I used a small subset of the Canvas API:

Scheme: https://codeberg.org/spritely/hoot-game-jam-template/src/branch/main/modules/dom/canvas.scm
JS: https://codeberg.org/spritely/hoot-game-jam-template/src/branch/main/game.js#L55

Since Phaser/Three.js are external libraries, you’ll also need to use npm or whatever to get the code.

1 Like

If you’re interested in Hoot, I’ve started working on an animation library. The idea is to build some useful abstractions over the 2D Canvas API. Unfortunately, it’s very immature right now, so I can’t recommend it. HOWEVER, it does contain plenty of examples of using Hoot, including:

Pre-loading images, HTML rendering with SXML, throttling the request animation frame rate, extending the interface between JavaScript and Scheme, Tweening, and Easing.

So, even if it’s not off-the-shelf usable, it contains ideas and code examples that might be helpful. It is based on Spritely’s official game template, which, Dave has already posted. start there. Then if you’re looking for more, you are welcome to explore my library.

Example working in a web browser: https://bonthron.com/protoculture/

Git repo: https://git.sr.ht/~bonthron/protoculture

2 Likes