Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. Going into this project our primary goal was to build our game map using procedural generation. This essentially boils down to algorithmically generating a random map with each game. This allows us to have a near infinite number of levels to our game and ensure that no experience is always the same. We knew that taking on this task was going to be very difficult, but we also had a couple ideas of how to go about it.
  2.  
  3. Our first idea was building a base for all of the future generation. We knew that we needed to build the map outside of just using the canvas, and we believe that creating a two dimensional array of cells was the best way to accomplish this. We built out a Grid β€œclass” that would take the given width and height as an argument so that we can customize how large or small we want our game to be. In addition to this we also declared an effective width and height dependent on those arguments to give our grid a border. Once we had the grid in place we moved onto generating rooms.
  4.  
  5. Now that we had A grid with cells in place, the room generation seemed much more achievable. We wanted this to work, by being able to tell our game how many rooms it should attempt to generate, and fit as many as you can on the grid. This allows us to control how populated our map looks. You are able to tell the room generator the minimum size as well as the maximum size for the rooms. The generator would attempt to build a room based on the minimum values passed, and would randomly select a width and height that fit within those bounds. It would select a random x and y coordinate on the grid, and attempt to place a room there. If the new room did not overlap an already existing room then it would place the room on the grid, change the cell values inside, and add itself to the list of rooms for the grid. After doing this it would begin creating the next room and repeat the process however many times you told it to do so.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement