I have been working on a game in javascript, and I'm stuck as to how to handle saving and loading. I want to ultimately publish it both as an online browser game and as a downloadable desktop application (which I'd do with electron). But for now it is just a browser game.
You can see it here by the way on my github page: https://jpchaufan.github.io/
What I have going now is not really working. I tried using local storage. The problem is that the game is kind of minecraft-like, in that it has an infinite world, that keeps generating as you walk around. When I stringify the world data into JSON, it is huge, like easily 6 million characters long, and potentially way more as the player walks around even a little bit. As a result, saving the game takes FOREVER, and practically crashes the browser if the world has been explored much.
I also tried another alternative, to try and avoid the limitations of local storage. I tried just printing out the save data for the player to copy and save manually themselves. Then give them the option of loading the game from local storage, or letting them copy in their own data to load. This didnt really solve the problem. It still takes forever to print the data out, and lets the player cheat too easily. I tried encrypting the data but it already takes too long to do, so it just made it worse.
Now I am hoping that this becomes easier on a desktop version of the game, or if I actually put the game online on a real webpage with a back-end. I actually would hope that the game can auto-save, so that the player can't go back if he dies or messes up. I mean my game is pretty simplistic compared to a game like minecraft or any MMO that has a big world.