So I am working on a way to randomly generate square/rectangle rooms and join them all together but kind of unsure how to approach it as I have never done random level generation.
I do not have much code to show but here is basically the approach I am taking:
for (int i = 0; i < 4; i++) {
polyShape.setAsBox(width, length,
new Vector2((length - width) * MathUtils.cos(lastAngle), (length - width)
* MathUtils.sin(lastAngle)), lastAngle);
fd.shape = polyShape;
wall = body.createFixture(fd);
lastAngle += 90 * MathUtils.degRad;
}
This creates 4 fixtures around the centre of the body, works fine as show below:
http://s26.postimg.org/y9thiw8jt/Room_Example.png
But say I want one of the walls to have a doorway? What would be the best approach? Only loop 3x and then create another 2 fixtures with a gap in the middle?
Then the problem goes…if I randomly generate these rooms, I need to find out where that gap is so I can have the next room through the door lol.
Sorry but level generation is all new to me