#### Archived

This topic is now archived and is closed to further replies.

# random dungeon generator

This topic is 6106 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m working an rpg that is completely random every time you play it based on what i learned in the articles Guy Lecky-Thomson wrote for game programming gems 1. I''ve gotten a pretty good terrain generator put together and now im working on my dungeon generator. Everything is coming together pretty easily except making randomly placed rooms. I can''t figure out how to place the randomly sized rooms without having them overlap each other. If anyone has any idea how to make an algorithim that can do this with out making overlapping rooms it be a huge help. Also whenever i output text, it flickers. Its not exactly a big problem but its really annoying.

##### Share on other sites
there is a thread in this forum somewhere about generating a random maze... i imagine if you used that algorithm and knocked down some more walls, you would get rooms of various sizes.
or, you could just randomly place your rooms, and if they overlap, either try again or slide them around.

--- krez (krezisback@aol.com)

##### Share on other sites
Diablo does a good job of this. If you use hallways as connector like diablo does, it should be very easy to build without overlapping, since there is so much space between the rooms. All you have to do is start at some room, and determine the number of exits, and what type they are. Then you generate the adjoing rooms or hallways and repeat recursively. You might have a list of fixed items a level must contain (such as one stairwell up and one down, 2 treasure rooms etc.), and slo some random kinds of rooms.

##### Share on other sites
Every room have a size that is a rect, right? That is to small. You must expand the rect a little bit. Then randomize the rooms position in a while loop and don´t let any rooms intersect with any other room.

  for(i=0; i= m_sMapDim.cx) pRum[i].pos.x -= (pRum[i].pos.x - pRum[i].size.cx); if( (pRum[i].pos.y + pRum[i].size.cy) >= m_sMapDim.cy) pRum[i].pos.y -= (pRum[i].pos.y - pRum[i].size.cy); bool bRoomIntersect = false; SetRect(&rcSrc1, pRum[i].pos.x, pRum[i].pos.y, pRum[i].pos.x+pRum[i].size.cx, pRum[i].pos.y+pRum[i].size.cy); if(i==0) break; for(int r=i-1; r>-1; r--) { SetRect(&rcSrc2, pRum[r].pos.x, pRum[r].pos.y, pRum[r].pos.x+pRum[r].size.cx, pRum[r].pos.y+pRum[r].size.cy); InflateRect(&rcSrc1, 1, 1); InflateRect(&rcSrc2, 1, 1); IntersectRect(&rcDest, &rcSrc1, &rcSrc2); if(IsRectEmpty(&rcDest) == false) { bRoomIntersect = true; break; } } // Break the while loop if(bRoomIntersect == false) break; }}

Zeblar Nagrim, Lord of Chaos

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 10
• 14
• 30
• 13
• 11
• ### Forum Statistics

• Total Topics
631788
• Total Posts
3002356
×