Closed grady404 closed 7 years ago
Shit, I just realized that multiplying two numbers (for the Level ID generator) doesn't always give a unique result. Idk what I was thinking. I will update the post.
Okay
While level IDs are not yet completely implemented, a save system was added to the game in version 0.4.0
. See issue #58 regarding level IDs.
Saving the user's progress will require a bit of an overhaul/update to the way levels are saved. Each level would be associated with a specific progress file, which would contain information about the player's best scores for moves, distance, and time (the file would not state whether or not the level has been completed, as the existence of the file itself would signify that the level was beaten). This would be saved in a completely different directory than the level files themselves, so that save data can easily be backed up. I'll go over a few potential ways to implement this system and highlight their flaws before presenting what I believe should be the final version of the progress system.
The first and most obvious idea would be to name the progress files
level1
,level2
, etc. to match the names of the actual level files. But a problem clearly arises if the level files themselves are reordered (and thus renamed) to make way for new levels or simply to change the order that the existing levels appear in the game. Then every time this happens, the progress files would correspond to the wrong levels. Another thing you could try instead would be to associate the progress files with the name of the level, but then if you rename any of the levels, the same sort of thing happens.So here's my suggestion: give each level a unique Level ID (in the
.json
file), and make the progress files correspond with the Level IDs. That way it doesn't matter if the level is reassigned a new level number, or given a new name, the user's progress will still persist since Level IDs never change. There are a couple of ways you could do this:level1
,level2
, etc.) but include the Level ID inside of the.json
file. Every time the progress for a level is loaded (by searching for the progress file with the same name as the level file), the game would check to make sure the IDs match. If they didn't (let's call said level file File 1A and said progress file File 2A), the game would go searching through all the other progress files to try to find one with an ID that matched the level file (File 1A), and if it did (I'll call the file it found File 2B) it would rename that file (File 2B) to match the name of the level file (File 1A) and then carry on as normal. But before it did that, the game would search through all the level files to find one with an ID that matched that of File 2A, and if it did (we'll call this file File 1B), it would rename File 2A to match that file (File 1B). I know, this sounds really confusing, and that's the major downside to this method, besides the fact that if you have a ton of level/progress files the game might take a while to carry out those searches, especially when the game gets to have a lot of levels.EDIT: Ignore this next paragraph, see #58 instead.
Yeah, I know this post was pretty long, but hopefully you'll find a way to implement this nicely (and soon) so players can start tracking their progress in the game.