Now With Web Simulator
One of the issues with releasing a Playdate game is not everyone has one! The simulator is pretty nice and easily installable from https://play.date/dev/ but not everyone wants to install yet another thing, especially one that might be commercially licensed. How can we make it easier to share our game with people that might not be able to install it?
For the last month or so I've been taking my game jam game and building a version that compiles to a Love2d compatible environment. Some of this has been done previously with https://github.com/GamesRightMeow/playbit but my game was written in a Lisp dialect called Fennel for the Lisp Jame Jam, so it's not directly compatible. Instead, I used it as an example and started building my own.
The pattern we use to accomplish cross-compiling a Playdate game to the web is two stage - first, build a version of the game that can run in Love2d, then, use a Love.js compiler to get it the rest of the way.
Love2d Build
Getting the Playdate game to run in Love requires replacing all Playdate specific API calls with Love2d equivalents (in cases of drawing primitives like rectangles), or writing replacements. Some of this was pretty straightforward, but other parts were rather complicated. Font drawing in particular, as different bitmap font formats are used, was hard to work out. Luckily that was already worked out by Playbit! With some tweaking I was able to use the script to convert the fonts used in the game.
Playbit also had already laid some of the groundwork figuring out a shader that converts all images to comforting black and white that looks like the Playdate simulator. I was able to use this as a base, though later found out it needed some fixes.
Beyond those bits, the rest was painstakingly replacing each of my stub API calls with working equivalents, cross checking the docs on Love (https://love2d.org/wiki/love) and Playdate (https://sdk.play.date/2.5.0/Inside%20Playdate.html). I completely sidestepped keyboard input (why rebuild that when compiling to a system with a keyboard), but overall most of the things Playdate does are also supported in the Love APIs. The things that had to be rebuilt entirely:
1. Sprite handling with collisions - moving with collisions was probably one of the hardest things to translate from online tutorials to my existing code - nobody writes tutorials on implementing this in fennel!
2. Pathfinding - I implemented my own A* algorithm but it seems to work a bit differently than the official one - sometimes my kitties still get stuck! I hope to work out why in future builds.
3. Input mapping - while love supports button presses, it doesn't support things like button _just_ pressed, which is a playdate API option.
Love.js Build
With a working Love2d build in hand, I could move on to building for the web. In theory, this should be easier as it's been done before, but there were still some rough patches to work out.
Shaders in Love2d are more allowing in syntax than the shaders in browsers, and this caused the game to immediately crash on first compile. This problem is documented in the Love.js readme, but I didn't figure out how to fix it until later - http://evanw.github.io/glslx/ was able to help me narrow down on the lines of the shader that were causing problems, mostly (some Love2d types are named differently and not supported by the checker - https://blogs.love2d.org/content/beginners-guide-shaders helped we figure out that bit of the puzzle)
Files
Get Princess Kitty Cafe
Princess Kitty Cafe
Serving the kingdom the very best in milk and tuna!
Status | In development |
Author | therabidbanana |
Genre | Simulation |
Tags | LÖVE, Playdate |
Leave a comment
Log in with itch.io to leave a comment.