danprince / midas

🫅 Traditional roguelike where everything you touch turns to gold.
https://danprince.itch.io/midas
2 stars 0 forks source link

Desktop Build #19

Open danprince opened 4 years ago

danprince commented 4 years ago

Want a version that can be played in a desktop client. Probably Electron for ease, but might be worth looking into other platforms.

danprince commented 4 years ago

The electron branch currently works in development but not in production because it reads files over the file:// protocol which doesn't support ES modules.

Looks like there are a few ways to get around that:

1. Run a http server from node

This would involve running a http server as part of the node process, that serves up the static version of the game. Would probably need something that prevented port collisions and it'd probably flag up security warnings on some OS (why would a game need to open a port etc).

2. Add a custom protocol

Could wait for/contribute the fixes for https://github.com/sindresorhus/electron-serve/issues/21 or write my own custom protocol wrapper so that the main file (and all subsequent requests) are served with the correct headers.

More details in this Gist https://gist.github.com/smotaal/f1e6dbb5c0420bfd585874bd29f11c43 Simpler version: https://gist.github.com/jarek-foksa/0f6e82bdaf8fb1962c9e14035a8725e4

3. Load the Live Game

Another option albeit a bad one, would be to load the live game's url. This is annoying because it means that the game wouldn't work offline, but also that it could update without you knowing.