Planning the level map
Before we start building anything, let's take a moment to think about how this automatic level building is going to work and what we need to do to build it.
Engage thrusters
We intend to create a maze-like level design viewed from the top, similar to the look of the conventional maps. We want to create varying levels dynamically, so we should break the stage up into tiles that can each contain a different graphic. All these tiles placed side by side will create the complete level.
Now for the math involved. We know the entire stage is 480 pixels wide and 360 pixels high. So the tiles have to be of a size that can easily divide the stage in equal segments without any leftover space. It's also useful if the tiles are square. This isn't mandatory, but it makes drawing tiles a bit quicker since it allows to rotate tile designs and still fit them within the same space. Refer to the following screenshot of the stage:
Let's summarize these requirements:
The stage is divided in...