GMH-Code / Quake2-WASM

Play the Quake 2 first-person shooter in your browser! Supports WebGL 1 and 2, and software-rendered modes.
https://quake2.m-h.org.uk
Other
15 stars 3 forks source link

downloading website to work offline without a web server? #7

Open Android986player opened 1 week ago

Android986player commented 1 week ago

how can I download the web version to an HTML file? I want it to be able to save, load, and load the game data

GMH-Code commented 1 week ago

Good question!

The game will just run from the buildable collection of static HTML/JavaScript/WebAssembly files -- but it needs a proper web server to host those files. You can't run the project from file:// links, because modern browsers prevent downloading (at least) from those kind of links.

This restriction isn't the fault of the Quake2-WASM project, but rather to do with your browser's security and the lack of headers. Emscripten needs to download multiple JavaScript/WebAssembly files, and your browser won't do this without seeing the proper headers from a web server. Without it, CORS restrictions, and other problems, like unknown MIME types (which are provided by a proper web server), will prevent certain actions on file:// links.

As far as I know, there is no way of bypassing file:// restrictions, and I really wouldn't recommend it anyway -- maybe if the WASM was integrated inside the JavaScript, it'd get further. This is possible, but again not recommended for various reasons, and it probably wouldn't run entirely anyway.

You'll need to either run a mini web server executable, or any other proper web server!

Android986player commented 1 week ago

I'm on chrome os though...

GMH-Code commented 1 week ago

Yeah, in that case the restrictions will apply just the same.

There is a way, I think -- on Android mobile devices, without root, you can run a 'localhost' web server as a service on a high numbered port, which you can then connect to from a browser with an address like http://127.0.0.1:8000/quake2.html, or similar. You should be able to do the same thing on Chrome OS, with the right app!