| Author |
how to go about making a mock dungeon
|
brent carter
Ranch Hand
Joined: Dec 15, 2011
Posts: 32
|
|
|
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: 2771
|
|
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: 32
|
|
|
thanks stephan. this was great advice and set me in the right direction
|
 |
Stephan van Hulst
Bartender
Joined: Sep 20, 2010
Posts: 2771
|
|
|
I'm glad it helped. Let me know how the project turns out.
|
 |
 |
|
|
subject: how to go about making a mock dungeon
|
|
|