The first 'room' to be placed into the array would start at the co-ordinates; (0,0-gridSize) to do this I initialised the Y variable with a 0-gridSize random number generator attached to it. The next form of randomisation involves deciding whether additional room values are an increment for X or an increment/decrement to Y (There is no decrement on X because I don't want the path to go back on it's self at this moment). I did this by creating 2 addition variables initialised with a random generator between 0-100(Xvar and Yvar). I then create an if statement to decide whether X will be incremented "(If Xvar <= 25)" else increment Y (if Yvar <= 50) else decrement Y. Adjusting the numbers in the if statement will ultimately change the shape of the dungeon.
At this time i had no way of graphically representing anything i'd done so until then i spent time getting familiar with Unity3D, a few tutorials later i managed to represent the values in my array by drawing cubes into the engine then transforming their X and Z locations by the X and Y values in my array respectively.
This is what i got :)
No comments:
Post a Comment