Advertisement
Hydrosaur45

Random Map Generator Walkthrough

Dec 3rd, 2018
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. A random cave is generated using "Cellular Automata". It's like the Game Of Life (if you've know what that is.)
  2.  
  3. It gets cut in half and the left part is salvaged.
  4.  
  5. A flag gets placed on a diagonal line, from (0, 0 (top-left)) and keeps going
  6. diagonally until it reaches a floor tile. It then goes down and right even more
  7. depending on the padding parameter.
  8.  
  9. A bomb gets placed next diagonally from the flag. It keeps going diagonally
  10. until the "bomb point" reaches a wall tile it then takes a step back and plants
  11. the bomb at that point.
  12.  
  13. Boosts also get placed in relation to the flag (since the flag IS the base).
  14. The boosts have basically the same algorithm as the bombs but instead of moving
  15. left the boosts move to the right until they touch a wall and they step back.
  16. Team boost gets placed the same except farther away from the flag.
  17.  
  18. Now, the Dig Paths Algorithm. It needs some work but I think its good for now.
  19. It looks for a boost and inverts the red flag point (because that's where the
  20. blue flag would be). Then it creates a line between the 2 points and "digs a path"
  21. by placing floor tiles in between the 2 points.
  22.  
  23. And gate placement; Gates are pretty similar to the dig paths algorithm. They
  24. get the 2 points (inverted flag point and boost point) and gets a line in
  25. between them. A gate rectangle is placed in front of the line of sight of the
  26. boost and the flag. The button is placed on the line as well, except its behind
  27. the gate.
  28.  
  29. The Routes algorithm was pretty fun to work on. It draws a line between the 2
  30. flags and creates a huge island in the center of the map with a hole in the
  31. middle of it, creating 2 big islands. But it doesn't only place walls. It also
  32. saves some "Route Points". There is "topLeft", "topRight", "topMiddle",
  33. "bottomLeft", "bottomRight", "bottomMiddle", and "Center". These are x,y points
  34. stored away from other algorithms to use. They represent the map routes.
  35.  
  36. Pups are placed using the route points. One pup is placed at "bottomLeft" point.
  37. Simple, since I have the route points.
  38.  
  39. Now spikes, I'm going to just generalize the hell out of this because I use the
  40. same "Diagonal Placement" tactic. It places spikes around bombs, boosts, and pups.
  41. (You can see some spikes ending up in walls, because the algorithm tries to add
  42. padding to the elements so you don't have spikes close to the elements.)
  43.  
  44. Boosts, again. Some more boosts are needed in the middle of the map,
  45. but because we have the route points its easy. A boost is placed at the topLeft
  46. point.
  47.  
  48. The Cleanup Algorithm. This algorithm ensures that there are no 1x1 tunnels or cracks.
  49.  
  50. Almost done!
  51. Now symmeterizing the map. This is simple, don't have to explain it.
  52.  
  53. Finally, creating an source image and a preview image for the map.
  54.  
  55. That's it.
  56.  
  57. Done.
  58.  
  59. All the rules.
  60.  
  61. Right there.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement