Jump to content
  • Advertisement
Sign in to follow this  
siliconsurfer

Linking Rooms (creating a dungeon)

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Ive started to do some game programming using C++ and SDL. (I'm not familair with game design) At the moment I've created a room, just a rectangle with collision detection to stop an object moving outside the room. What I want to do is create a second room and link the two, so an object can walk through a door into the second room, the players view would then move from the first room to the second room as the object goes through the door. (along the lines of the first Zelda game when the character moved from one dungeon room to the next). Has anyone got suggestions of how to do this, where I can look for information tutorials etc and what sort of data structure would implment this.

Share this post


Link to post
Share on other sites
Advertisement
Assuming a single room is displayed on screen at a time, you could quite easily define a list (perhaps std::list or std::vector, allowing you to have numeric IDs as an index). From here, define exits from each room which contains either a direct pointer to the room to go to or just the ID which is then used to look up the room. Assuming your game code is geared up to allow you to act upon a single room at a time, it shouldn't be hard to make it reference your new room.
A few months ago I knocked up a really basic text adventure room layout structure for a user on GameDev, perhaps you could find a use for it (here)

Share this post


Link to post
Share on other sites
I made an SDL game like this once. I just set it up so it drew a bunch of tiles to the screen, and if you walked off the map it would load the next map in that direction (through a couple witty sprintf calls).

That way, if I didn't want a user to go in a particular direction, I'd just block it off with a wall.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!