Advertisement

First Person Dungeoncrawler - map structure

Started by March 01, 2019 04:08 PM
4 comments, last by gumbosoup 5 years, 6 months ago

Hi there!

I'm currently working (design stage atm) on a retro-style first person dungeoncrawler, in the vein of classics like Wizardry, Bard's Tale, Might & Magic, Legend of Grimrock etc.

My problem is as follows:
The basic way to set up the game map is a simple grid. 0 for floor, 1 for wall, 2 for door etc, so basically a wall cannot be thinner than one grid space. However, I really like the way Bard's Tale has its dungeons - walls are in between grid tiles, so you can have an infinitely thin wall and you can pack much more content on a smaller surface. Also, I feel the dungeon is much more immersive that way, as in purely tile-based design the walls are waay too thick.


So, how to set this up? It's easy enough with your basic tile system, a simple 2D tile array will do. How to do it the other way? Also, the engine would have to be capable of displaying different graphics for different sides of a wall as well as separate objects on different wall positions (buttons, keyholes, niches...) I know I could brute-force it with trickery and patchwork but I'm looking for an elegant solution to this because a( I love elegant solutions and b) it would make creating a dungeon editor much easier.

So anyone of you old hands have any experience/idea on this?

/edit Oh and clarification: I'd really like to do it old style - pure 2d sprites underneath so no "why don't you just slap it in 3D map editor" or smtn... I'm really interested in how those old wonderful old timey RPGs worked.

 

Well, firstly, do you need a grid at all? You can just have all your geometry have an arbitrary position, as they would be in a full 3d game.

However, if you want to stick to a grid, one option is to start thinking in terms of vertices rather than grid squares so that your walls are  defined as edges between two vertices. You can either transition to fully vertex based in which case you probably want to define your tiles in terms of rectangular areas, or you can have both and define some stuff on vertices and some on grid. It's up to you to figure out what you prefer for your game.

Another alternative is to have a 4 bit mask for each grid square specifying if there is a wall up/right/down/left of the square.

Advertisement

Thanks!

I've thought about what you call the mask approach but it seemed a bit fiddly to me (2d array holding an integer describing what walls are there)... And its good only if you have one type of walls (and what about doors etc?) Perhaps a 3d array...

Can you elaborate more on the vertices approach though? Say there's a 2d array of all the points, intersections between the tiles,.. where do I go from there?

Oh and as for grid, I'm really into old-time retro thing and it genuinely interests me how to do it with minimum cpu or memory footprint, like in the old days also.. dunno, doing it through 3D just wouldn't "feel" right. I believe it would even rub on player experience.

It's easy enough to add other types, just add another 4 bits to the mask. A single 32-bit int could hold 8 types for example, in fact, since you've got a limited number of tiles, you could probably want to pack your edge types in with your tile types and any flags for other things happening in your tiles anyway. You then just have one array for all of it.

So, for vertices, if you want to go full vertex based. Instead of an array holding each individual tile, you store areas of each tile type, non-overlapping is easiest to process in code and easy enough to make your editor produce, but you can also do hierarchical if you like. Finding out what tiles are within an integer, axis-aligned rectangle is super-easy so it should be efficient to fill out the visible area but you can use binary space partitioning to subdivide larger maps if you think it necessary. If you have largely uniform floor tiles, this kind of approach should take up less memory than a grid, if you vary a lot it won't.

Whether you want a full vertex system, or a hybrid one, walls as start/end pairs, making sure these are axis-aligned. When you're doing your casts to find tiles in the visible area you just need to stop at the walls, easy enough.

The one thing to watch for is the difference in numbering of grid squares and edges, you'll get a sort of off-by-one effect because for N grid tiles, you'll have N+1 vertices along each edge. This isn't a huge problem, it's just kind of confusing to think about.

Thank you so much! Lotsa good ideas to digest and try out. Thanks!

This topic is closed to new replies.

Advertisement