Metroidvania Month 7 Day 6

Hey, I know it might say "Published 2/21/2020" so it should be Day 7 instead, but I was thinking about an idea I had for the save files just now and I wanted to type them up before going to bed.

The question rattling around in my head was this:  how do I save the exact power-up that I've collected?  Simple: we store an ID in an Array.  The save file will be a JSON object and within that we could have arrays for each max ammo and max health power-up type.  Say in the game we have Tanks that store extra health.  In our SaveFile JSON object, we would have an Array called "tanks" that just stores IDs of collected Tanks.  When we enter a room that has a Tank, we search SaveFile.tanks array for the ID of that Tank.  If the ID is found, don't spawn that Tank, otherwise, we spawn it if it hasn't been collected.  What is the maximum collected Tanks that we should fill?  SaveFile.tanks.length should give us the maximum Tanks to fill.

After answering that question, my mind jumped to another one:  how do I save the Grids that the player has explored?  I'm thinking that I should do a 2D Array for each Area of the game.  I picture 2D Arrays as a table, as in array[row, column].  So, if our player is exploring AreaA, I would look at SaveFile.areaA[gridY, gridX].  The gridY is our current "row" and gridX is our current "column" on the map.  Each cell in this 2D Array will have an object that just has two Boolean variables: visited and itemFound.  When drawing the cells in our map for AreaA, we would check SaveFile.areaA[gridY, gridX].visited to see if we need to draw the cell or leave it blank.  If we had visited that cell and it had an item, we can then check SaveFile.areaA[gridY, gridX].foundItem to decide if we need to indicate if there's an item still left for us to find in that cell.

I'm just trying to figure out the best way to write the SaveFile to make it efficient when using it to check progress.  It's really trying to keep the Big O Notation down for things I might have to load or change constantly.  I really like my idea for the map, since it's instant (O(1)) due to being able to go to the exact cell and reading/writing that variable.  It might be a pain to search through the whole tanks Array (O(N)) every time we enter a room with a Tank power up, but how many times are we going to be doing that search?  Not very often.  Plus, if I made tanks like the one for explored Area, then I wouldn't be able to use SaveFile.tanks.length (O(1)) for I would have a Boolean in that Array for every Tank in the game from the start.

Anyway, I got to go to bed now.  I hope I can actually start coding the thing after work.  Here's the link to the repository for Daemon.

Comments

Popular posts from this blog

Game Off 2019 Day 4

Hacktoberfest 2019 Day 8