
PiBrain
1545
5
7

A sample opening of a level, we will focus on these 12 objects (not including any walls or the player). We have 2 boxes, 2 buttons, 2 doors, 2 pressure plates, and 4 fans.

The full map

This is what the game sees as it reads the first map file, a bunch of characters that are mapped to certain objects: ‘b’ for buttons, ‘d’ for doors, ‘w’ for walls, ‘h’ for boxes, ‘H’ for pressure plates, and ‘F’ for fans. The objects are loaded from a folder containing all of the prefabs, how it knows what object to use for ‘d’ is defined in a separate file. Next the revolutionary technique of looping though the map file and placing the objects on that x – y coordinate in the game world is employed. After placing the objects, it stores the object in a dictionary, which comes in handy later. Walls check all of their neighbors to see if they are walls as well and update themselves accordingly to use the correct sprite. This is all the first file does ~52.8 KB down.

Just some pretty colors to keep the zoomers entertained.

The second map file is where all the fun happens, where the connections are defined. This is used to create connections between objects. The picture shows a section of the file that is used in the same map but aren’t exactly what is used in the opening, as they are sorted by type. Each object contains a script that derives from the same class, which has the set-up function int it. Each line is fed to the correct object by looking into the dictionary from earlier. Once the object gets the correct line it looks through the data it was given and decides what to do with it; fans set their power and rotation, buttons connect to other objects for turning on and off, etc ~5.24kb down.

Now this is not useful if we can’t even make the files, we could do it by hand but who would do that (besides me of course). So, we have a map builder that uses a nice interface that allows us to define where things are and how they connect. This will read all of the connections that are made and put them in nice rows that the map builder can use. As well as putting all the characters in the main map file.

Well, we can create the files and read the files but how do we know what files to load and where to find them? If we don’t know where they are then we did all of this work for nothing. We have a baseline folder where there is always a reference towards, so let’s use that. We can use another file that we always have within that folder to store all the names of the files that we can read, so we can get all of the file names for UI reasons and when we want to load a file we know its exists.
Antheridia
This is giving me strong Apple II+ nostalgia ❤️❤️❤️
Lomish
Tiled also works wonders, draw map, base64 encode, WAY smaller then 57kb :)
PiBrain
Tiled is a great tool, and I could get it down more if I removed a lot of the placeholder characters down to ~20 KB, but the map editor is in game so people can make their own maps.
Clockworkdancerobot
C64 game designers: "Not bad."
PiBrain
Thanks!