Jump to content

  • Log In with Google      Sign In   
  • Create Account


Room Based Euclidean Map


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 dsm1891   Members   -  Reputation: 595

Like
0Likes
Like

Posted 06 March 2014 - 12:59 PM

Hello all,

 

I have been stuck on this problem for about 2 weeks, and I think I have hit every brick wall possible, so alas  find myself here. I am currently creating a 2D rogue-like game (c++) with map elements not to dis-similar to the game Rogue Legacy. The level map is comprised of different rooms of different sizes that have entrances/exits to rooms that are adjacent. It's a little hard to explain, but hopefully this picture of Rogue Legacy which shows the game map will help.

roguelegacy-2013-06-28-01-28-15-84.png

And here is a crude paint drawing (where green arrows are entrance/exits)

UUyGzDw.png

 

 

Currently I am generating a map using a modified pathfinding algorithm which gives me my desired layout of rooms. 

 

DzDwsbu.png

 

I currently run the map generation store the rooms in a 2D array. Once all of the rooms have been generated, I then run through the array and place portals (entrance/exits) in the relevant rooms and set their destination room.

 

This works perfectly at the moment, where all the rooms are the same size. However adding larger rooms that can have more than the standard 4 portals (Left,Right,Up and down) is turning out to be a little tricky, as I am having trouble calculating the destination room and/or the position in that room.

 

 

Any help would be greatly appreciated, if you need anymore information just let me know :).


Edited by dsm1891, 06 March 2014 - 01:12 PM.


Sponsor:

#2 Hawkblood   Members   -  Reputation: 717

Like
0Likes
Like

Posted 06 March 2014 - 01:52 PM

You could make your room "portals" as vectors:

vector <int> portal[4];

where the [4] is the 4 cardinal directions. The vector would hold all the "room numbers" associated with that direction.
For example:

room (0,1) has 0 portals N, 1 portal S (room (2,2)), 2 portals E (room (0,2)), and 2 portals W (room (0,0) and room (1,0))


I don't really know how you are accounting for your rooms, but this should give you something to think about.

#3 BitMaster   Crossbones+   -  Reputation: 3659

Like
1Likes
Like

Posted 07 March 2014 - 02:40 AM

When considering Rogue Legacy, there are a few things to consider first (the following is based on observation, not being involved in the game). The individual rooms are not randomly generated. There is a (large) set of handmade rooms available. These rooms have several exit locations. These exit locations can be 'open' or 'closed'. Exits in 'closed' state seal off an (again handmade) area of the room with blocking tiles.
Each room has an integer size in map-tiles (I believe from 1x1 to 3x3, although I haven't played the game for a while). One map-tile is always NxM room-tiles big (the actual number does not matter, the point is you can easily fit rooms together in a map like that and exits are always in the center of a map-tile edge).

These design decisions make a Rogue Legacy-like map generation actually a lot easier. In pseudo code:
Place the starting room.
While the map is not big enough:
   Pick a random 'closed' exit E in any room already placed
   Pick a random room R from the library of possible rooms (all exits of this new room are 'closed')
   Pick a random exit E' (opposite direction of E) of R and try to place it in the map so that E and E' connect
   If that is possible without overlapping with existing rooms in the map: (*)
      Place R in the map
      Iterate over all other 'closed' exits of R
         If there is a corresponding 'closed' exit in the room in that direction, set both to 'open'
The check at (*) is actually extremely simple. Since everything is neatly on map-tiles, there is exactly one way how you could place the room in the map and the check could be as simple as a bitmap with one bit for each map-tile.

Edited by BitMaster, 07 March 2014 - 02:41 AM.


#4 Stainless   Members   -  Reputation: 655

Like
0Likes
Like

Posted 07 March 2014 - 04:24 AM

I really like the technique described above, and I've seen several other techniques described in various articles scattered across the web, but if you want to experiment I have an idea that should work.

 

First add all the rooms to the map, use a force based system to give some separation between the rooms.

 

Then walk the map vertically and horizontally shooting rays from each room, record the first room the ray intersects.

 

At the end of this, for each room you will have a list of rooms that it could link to below and to the right, and a count of how many possible links exist.

 

If this count is greater than a pre-set value, randomly pick one of the rays and add doors at both ends.

 

At the end check all the rooms to make sure they have at least one door. If not pick a ray at random and add doors. If no rays exist, remove the room.

 

By using a ray based system, rooms can be any shape you like. As long as you can find a ray - shape intersection test, it will work.

 

I also have some ideas for corridors, but that's for another post.



#5 dsm1891   Members   -  Reputation: 595

Like
0Likes
Like

Posted 21 May 2014 - 04:27 AM

Hi,

Sorry for the late reply I kinda forgot about this thread.

 

The problem with the suggested methods above is that I first create a paths, then traverse the nodes (A.K.A the matrix along the path) populating each position with a random room.

 

You can read about my map generation algorithm (RBES) here: http://www.davidmarshall.info/rbes.html

 

but the TL;DR version is:

populate the map assuming all rooms are the smallest size

once the population of the map has finished, check and deal with overlapping. Then check the size of the rooms and link to adjacent rooms/subrooms for how ever many subrooms are on the parameter.

(a subroom being the space a minimum room could fit into)

 

Sorry for late reply, but I hope this will help somebody in the future :)






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS