Pilum Playable Demo
First Written Tue Nov 14 02:59:40 2023
File Modified Wed Feb 14 18:32:26 2024
Latest Upload Fri May 2 12:48:25 2025
When talking to my friend Jessey, he asked me why I had never made any of my games playable on my website. After all, he'd played my old Game Maker games back in middle school.
While my Game Maker games existed only as executables and not something I could serve up in the browser (at least not without upgrading them several versions into the future and buying new licenses), Godot has the option to export as HTML5.
The catch is: I've never actually finished a Godot game before.
Well, that's not entirely true. I do have demos and prototypes. Which is what I was inspired to upload onto my site after our conversation.
There were more than a couple snags.
First, I wanted to try uploading a demo for Pilum, as it was a small and concise project with a working demo map. This was a problem because I had started that project in Godot 3, and was now using Godot 4 for any future work.
Rather than reinstall an older version of Godot, I converted the project in the name of not looking backwards.
For my own future self's sake as well as any readers', I'll list the issues I had to solve:
- Typed export variables now had a different syntax:
- Old:
@export (VariableType) var my_var = default_value
- New:
@export var my_var: VariableType = default_value
- Old:
update()
is nowqueue_free()
- The
Navigation2D
class is now gone, but thankfully I only had one reference to it as I had switched to usingAStar2D
TileMap.cell_size
is now accessed viaTileMap.tile_set.tile_size
TileMap.get_cellv
is nowTileMap.get_cell_source_id(0)
- Tile maps now have layers, e.g. layer 0, which I had to switch several functions to using
- For reasons I've yet to understand, I had to switch the operands in a few instances of
a.angle_to_point(b)
- The way I was resolving mouse event locations relative to the camera broke when viewed in a browser
- Thankfully
get_global_mouse_position()
was unchanged (and a much simpler solution)
- Thankfully
Finally, once I'd managed to export my project, I had trouble hosting the game directly on this site:
- I use Flask to run this site, which lets me serve a page with whatever route I desire
- This is great elsewhere, but the exported Godot game had hardcoded paths that I had to fix up, so that it could find its pieces
- As of this writing, Godot 4 HTML5 exports require SharedArrayBuffer which meant I had to enable cross-origin isolation
- Doing so required me sending new headers on this site's responses, and also broke a lot of resources
- Most of my site's media is embedded from other sources, meaning a lot of pieces to fix
- Even trying to run the generated HTML5 export in a browser for local testing threw the SharedArrayBuffer errors
- Doing so required me sending new headers on this site's responses, and also broke a lot of resources
In the end, I gave up and just put the game up on itch.io:
I even tried embedding the game on this site via their embed code, but that just lead to the same SharedArrayBuffer error message.
<iframe frameborder="0" src="https://itch.io/embed-upload/9089455?color=333333" allowfullscreen="" width="1760" height="900">
<a href="https://kieferandco.itch.io/pilum">Play Pilum on itch.io</a></iframe>
Good luck trying to kill everything on the map!
And more!
–Kiefer