Random Map Generator Walkthrough
Hydrosaur45 Dec 3rd, 2018 (edited) 256 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- A random cave is generated using "Cellular Automata". It's like the Game Of Life (if you've know what that is.)
- It gets cut in half and the left part is salvaged.
- A flag gets placed on a diagonal line, from (0, 0 (top-left)) and keeps going
- diagonally until it reaches a floor tile. It then goes down and right even more
- depending on the padding parameter.
- A bomb gets placed next diagonally from the flag. It keeps going diagonally
- until the "bomb point" reaches a wall tile it then takes a step back and plants
- the bomb at that point.
- Boosts also get placed in relation to the flag (since the flag IS the base).
- The boosts have basically the same algorithm as the bombs but instead of moving
- left the boosts move to the right until they touch a wall and they step back.
- Team boost gets placed the same except farther away from the flag.
- Now, the Dig Paths Algorithm. It needs some work but I think its good for now.
- It looks for a boost and inverts the red flag point (because that's where the
- blue flag would be). Then it creates a line between the 2 points and "digs a path"
- by placing floor tiles in between the 2 points.
- And gate placement; Gates are pretty similar to the dig paths algorithm. They
- get the 2 points (inverted flag point and boost point) and gets a line in
- between them. A gate rectangle is placed in front of the line of sight of the
- boost and the flag. The button is placed on the line as well, except its behind
- the gate.
- The Routes algorithm was pretty fun to work on. It draws a line between the 2
- flags and creates a huge island in the center of the map with a hole in the
- middle of it, creating 2 big islands. But it doesn't only place walls. It also
- saves some "Route Points". There is "topLeft", "topRight", "topMiddle",
- "bottomLeft", "bottomRight", "bottomMiddle", and "Center". These are x,y points
- stored away from other algorithms to use. They represent the map routes.
- Pups are placed using the route points. One pup is placed at "bottomLeft" point.
- Simple, since I have the route points.
- Now spikes, I'm going to just generalize the hell out of this because I use the
- same "Diagonal Placement" tactic. It places spikes around bombs, boosts, and pups.
- (You can see some spikes ending up in walls, because the algorithm tries to add
- padding to the elements so you don't have spikes close to the elements.)
- Boosts, again. Some more boosts are needed in the middle of the map,
- but because we have the route points its easy. A boost is placed at the topLeft
- The Cleanup Algorithm. This algorithm ensures that there are no 1x1 tunnels or cracks.
- Almost done!
- Now symmeterizing the map. This is simple, don't have to explain it.
- Finally, creating an source image and a preview image for the map.
- That's it.
- All the rules.
- Right there.
RAW Paste Data