pmotschmann / Evolve

An incremental game about evolving a civilization
Mozilla Public License 2.0
858 stars 371 forks source link

*SUPER IMPORTANT!!* GAME DOES NOT LOAD IF DOWNLOADED!! *SUPER IMPORTANT!!* #966

Open GhostieKoto opened 1 year ago

GhostieKoto commented 1 year ago

This game doesn't load AT ALL when downloaded. You need to figure out why and fix it, please.

fredden commented 1 year ago

@GhostieKoto please can you provide some instructions for how to reproduce this? What steps to you take to "download"? Are you perhaps using your browser to save the page as a file locally (with right-click, 'save as...')? I don't see any mention of "download" in the README for this repository.

GhostieKoto commented 1 year ago

@GhostieKoto please can you provide some instructions for how to reproduce this? What steps to you take to "download"? Are you perhaps using your browser to save the page as a file locally (with right-click, 'save as...')? I don't see any mention of "download" in the README for this repository.

I clicked code, downloaded the files as a zip, and launched index.html.

I think I also tried extracting all before launching index.html

GhostieKoto commented 1 year ago

@GhostieKoto please can you provide some instructions for how to reproduce this? What steps to you take to "download"? Are you perhaps using your browser to save the page as a file locally (with right-click, 'save as...')? I don't see any mention of "download" in the README for this repository.

The school blocked all deployments. Which is super fricking annoying as I'm in a game development class. :/

So no GitHub.io, no vercel.app, no repl.co, etc

fredden commented 1 year ago

I've been able to run the game locally from a checkout of the repository by running a simple web server with: python3 -m http.server. I've not attempted to run it from a file: scheme.

GhostieKoto commented 1 year ago

Well, are you able to fix it so it can run as a file?

GhostieKoto commented 1 year ago

It would mean a lot to me

fredden commented 1 year ago

This seems to be a limitation imposed by the browser, not a bug in this game. See https://github.com/whatwg/html/issues/8121

Screenshot_2023-10-16_10-04-23

StoneCypher commented 1 year ago

@GhostieKoto - three things.

  1. The game runs just fine if you download it. The most likely source of your problem is what Fredden gave a screenshot of, but didn't explain how to cope with: how you're loading it.
    • The browser is much stricter with locally hosted things (mostly from file:/// and 127.0.0.1) than with other sources, because if you're tricky about things, you can get access to things on disk using relative paths
    • You are attempting to load from a file:/// url. The game is built from relative URLs, meaning it loads all its assets from wherever the base was loaded. This means it's trying to load the scripts from file:///. That's a no-no.
    • You need to do two things to fix this:
      1. Host it from a local webserver (easy and free)
      2. Provide a name for that local webserver which isn't 127.0.0.1 or localhost, the normal names for your own computer, because they'll end up with the same issue
    • Setting up an alt name is piss easy - you just set up your hosts file to point some name you pull from thin air to point somewhere
      • It's good practice to use a name that isn't a legal web address, like http://evolve/ or http://evo.lve/, so that it can never collide with a real address. Plus it's fun
      • Here are hosts file instructions for various platforms. It's literally just "open this text file and add a line, then save. If your browser already used that address today, restart your browser too."
      • The recommended line here is 127.0.0.1 evo.lve # loopback for evolve for cors
    • There are a million ways to install a local webserver.
      • You could install a production webserver like apache or whatever, but that's a hassle, and since this webserver can be flimsy, it's probably easier to do something else
      • When I'm in a situation like this, I install some easy programming language, like node or python, and then install a development webserver from their package manager
        • You could install node and install servehere, which I wrote for exactly this kind of situation
          • install node
          • npm install -g servehere
          • go into wherever you downloaded the game
          • servehere -p 9123 -c
          • go to http://evo.lve/ , should now work
        • You could install python and install simplewebserver, which someone else wrote for situations like this
          • I don't python, no instructions here, sorry
  2. You will need to export your existing save and import it to the new hosting, because of the way browser localStorage works. They count as different webpages due to the address change, and different webpages aren't allowed to look at each others' storage for obvious security reasons
  3. Probably don't write *SUPER IMPORTANT!* on your issues in the future. If I saw an issue like this on one of my repos, this would go to the very, very back of the queue, over this behavior.