File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Game Development and the fly likes how to go about making a mock dungeon Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "how to go about making a mock dungeon" Watch "how to go about making a mock dungeon" New topic
Author

how to go about making a mock dungeon

brent carter
Ranch Hand

Joined: Dec 15, 2011
Posts: 34
Hey guys. I am trying to make a 4x4 (16 room) cave for a mock rpg I am making. What would be the best way to work out the travel mechanism. I am surely going to make every room its own class. I could do it by making a whole bunch of if else statments (if selection.equals("north") run room A3 etc.) I was just wondering if there is a better way to go about doing this. Thanks
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3611
    
  14

No. Don't make every room into a new class. This is not going to scale. Instead, you should think about a way to describe a room in some data format, and then use the description when you create a new instance of the Room class.

Part of this description could be which other room a room passes into in a certain direction. You can make an enum Direction which contains constants like NORTH, EAST, etc. The Room class could have a method that takes a Direction and returns an adjacent Room.
brent carter
Ranch Hand

Joined: Dec 15, 2011
Posts: 34
thanks stephan. this was great advice and set me in the right direction
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3611
    
  14

I'm glad it helped. Let me know how the project turns out.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to go about making a mock dungeon