Devlog #1 - Map system


Hello and welcome to the first devlog of Switch Jump!

This devlog will focus on the first post-jam update for the game, which came in the way of saving and loading maps.

History

The game was made in pico-8, in such a way, that i needed to draw every single map on the map, and load it from there, offsetting the camera and the player to enter the right map, and load the map's features, like boosters, enemies, and geysers (the bouncy thingy).

The game was built in such a way, that i would log the place for the enemies on the map, and add them in code, not in the map sheet, like this:

And let be hones this is ugly, not optimal, and wastes all the percious tokens and such from everything else. Also as there is only limited space on the map sheet, i can only have so much maps. I opted for 7, which was easy to maintain and manage, but let's be honest, it is not really a lengthy experience.

Encoding Maps

So i looked into drawing my maps, exporting them in some form, and loading them runtime for the game, which will allow me to have way more maps. The code part was easy most of the time, i just iterate through the map, save all the ID's and done!

 

Or so i thought. 

You see, my geysers and boosters are done in a particular way. Before, i placed the correspondig tile, and just added the corresponding booster on the tile above it, so if you collide with that object, you will get boosted. As booster have the same force, this part was easy. But geysers were not. The problem with geysers is, they have a force, which is not the same amongst all of them. Some will launch you slightly, some will launch you to the top of the map. My first thought was, lets just set a few values to have as choices for launch force, and create a new tile, that will indicate the force of the launch:

  

The lines correspond to different launch forces. This works really great, unti you have the problem with the picture under it. The game has a mechanic, where switchable block can block geysers, and these blocks are shown with the dashed if allow, and full block if not. You see where i'm going with this? Above every geyser i should have a tile, showing the force of the geyser, and on the same spot(!) i should have a switchable block. Yeah, that's not happening. So i introduced two new tiles (now 6 new with the geyser force indicators), to show if the geyser shall have a block above it, not have one, or should be a regular one:

.

If you look closely, you will see, that the rightmost bottom geyser has a different sprite, showing, that it will have an off block, and the middle left one, next to the ghost, it has a different  (not so, but still) tile as well, showing that it should have an on block on it.

The decoder:

https://gist.github.com/Achie72/50b84716ee33a3e76577acad7e72d5fd

This code is still unoptimized, but it's disgusting form comes from the fact, that some if my tiles have a one digit ID, some two digit, and some three digit, so i have to prepare for everything,

After this decoding happens, i have a table of ID's which i just iterate through, and set the corresponding tile for the corresponding ID, and create my geysers, boosters enemies. This part is ugly as it is a bunch of for cycles and if's so you have to believe me on this. And after all this i just have to load the map, and it is playable:


"But why?" you ask

I mentioned already, but as of now the game can have 7, at max 10 maps with it's current archicture. BUT after this change it goes way beyond that. My tokens are fine, only exhausted the third of my token limit, my char limit is ~64k and i'm around 18k, and every map will cost me at most (this is way overshooting btw), 675 character, and around 20 tokens at max. This new change will allom me to have more than 50! maps in the game, and have leftover characters to, without ever touching anything in the code.

So yeah, up to 50 maps in one cart, which is way more than i should have, i think. Also creating maps is as easy as drawing them, exporting the string, and adding that string to a collection. And the code handles the rest. So later i can publish the map generator, the code, and everyone can make their on level collections, and maybe publish them here, who knows!

Well, after all this text, i will thank you for your attention, and i hope we will se each other next time!

See ya

Leave a comment

Log in with itch.io to leave a comment.