Temple of The Roguelike Forums
Development => Programming => Topic started by: Vanguard on April 25, 2009, 09:59:50 PM
-
Hey everyone!
I'm working on a roguelike project, but I'm still pretty inexperienced as a programmer, so I thought I would ask for advice on this.
How should I connect the stairs in different floors with each other? I'm going to have persistent levels and sometimes the dungeons will have branching paths, so I can't just have a depth variable that I add or subtract 1 from. The best thing I can come up with is by making each floor its own subclass of the stage class, something like this:
class Tower1 extends Stage {
Tower1() {
int numberOfStairs = 2;
stairs[0] = worldMap;
stairs[1] = tower2;
}
}
class Tower2 extends Stage {
Tower2() {
int numberOfStairs = 3;
stairs[0] = tower1
stairs[1] = tower3;
stairs[2] = tower4;
}
}
worldMap, tower1, tower2, etc would all be constant variables for referencing each map.
Oh, and I'm using Java if that makes a difference.
-
Looks reasonable and I am sure it will work. There are no best ways to do this, yours is good.
Next problem is linking the tile with stairs in it to the correct stairs[X] reference.
This could easily be extended for multiple stairs to the same area if needed.
-
Create stairs object that has destination level and destination stairs id stored in it.
-
Step 2 Create Roguelike. ;D
-
The real problem is determining the connections between level branches. I'm having problems with that myself, because the tree structure is too much for me to handle. Maybe the dungeon could be divided into theme based areas (one or more level) with connections to other areas (level themes). Or then the branches itself could be named so they know where to connect.
-
Just treat them as different dungeons. D20 connects to D21 and L1, L5 connects to U1, U15 connects to D40, etc.
-
Just treat them as different dungeons. D20 connects to D21 and L1, L5 connects to U1, U15 connects to D40, etc.
That is the theory. In practice it's always a bit more complex. By the way, I'm implementing stairs (and dungeon structure) in Agduria. I managed to make some kind of system with stairs between sections (themes) but still have to figure out how to connect themes to each other. Check out the source code of latest Agduria version (world.cpp contains the level node connection code):
http://koti.mbnet.fi/paulkp/agduria/Agduria0509n.zip
-
I appreciate everyone's advice. It's up and working now. I did it essentially the way it's done in my post.
I connected the stairs to each other by checking where you're coming from up against where you're going to, and it sets the player character's location to that of the matching set of stairs. As long as I don't make two sets of stairs in one level that both lead to the same level there won't be any problems with this, and I don't think I'll ever have any reason to do that.
-
My stairs are usually just standard objects with a destination level and location. The stairs are always generated in pairs though, so if I want to link level 5 and 10, I would generate a corresponding staircase in each, pointed to the level and location of the other.