Kiefer Co:
@kieferandco
KieferAndCo
ChairmanCo

My Favourite Humans

Pilum Playable Demo

First Written    Tue Nov 14 02:59:40 2023
File Modified    Wed Feb 14 18:32:26 2024
Latest Upload    Thu Sep 19 03:09:54 2024

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.

The Pilum demo being played

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:

Pilum being opened in Godot 4 with errors
  1. Typed export variables now had a different syntax:
    • Old: @export (VariableType) var my_var = default_value
    • New: @export var my_var: VariableType = default_value
  2. update() is now queue_free()
  3. The Navigation2D class is now gone, but thankfully I only had one reference to it as I had switched to using AStar2D
  4. TileMap.cell_size is now accessed via TileMap.tile_set.tile_size
  5. TileMap.get_cellv is now TileMap.get_cell_source_id(0)
    • Tile maps now have layers, e.g. layer 0, which I had to switch several functions to using
  6. For reasons I've yet to understand, I had to switch the operands in a few instances of a.angle_to_point(b)
  7. 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)

Finally, once I'd managed to export my project, I had trouble hosting the game directly on this site:

Pilum throwing errors due to missing SharedArrayBuffer and Cross Origin Isolation
  • 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

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!

Desert horse archers in Pilum

Nomadic horse archers in the desert.

A crocodile and Vulcan in Pilum

A nile crocodile and an angry deity in the lava.

Tower worshippers in Pilum

A worker uprising and their beloved archer tower.

Hyaenas and a tank (yes) in Pilum

Hyaenas and a tank (yes) in the snowy wastes.

Extremely fast swordsmen in Pilum

Cybernetically enhanced swordsmen who can walk on water.

And more!

Tags: Blog, Pilum

–Kiefer