Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411276 Posts in 69323 Topics- by 58380 Members - Latest Member: bob1029

March 28, 2024, 10:30:43 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Dungeon generation?
Pages: 1 [2]
Print
Author Topic: Dungeon generation?  (Read 28134 times)
st33d
Guest
« Reply #20 on: September 29, 2009, 01:40:47 PM »

*bump*

Any ideas on platformer generators? I've got a lode-runner controls type project that's got me scratching my head here. Throwing any kind of map at the player seemed really simple till I decided to go down the no-jump-ladders-only route.

The levels are essentially dungeons, so I've already started out with a room concept (the game is a big homage to Rogue). Plus it looks nice when the light raycaster blooms into a room. But connecting the rooms and judging where to slap ladders and press-down-to-drop-thru ledges has me stumped.
Logged
st33d
Guest
« Reply #21 on: September 30, 2009, 06:33:21 AM »

Brilliant stuff, more essential reading - much thanks.
Logged
st33d
Guest
« Reply #22 on: October 13, 2009, 12:01:21 PM »

Got a basic map generator working by setting it to favour using old paths and quitting out of long tunnelling operations. I very rarely get a broken dungeon, but I can use Flash's bitmapData to floodFill from each room and verify the network is connected.

Demo with source code
Logged
Hayden Scott-Baron
Level 10
*****


also known as 'Dock'


View Profile WWW
« Reply #23 on: October 13, 2009, 01:24:23 PM »

Got a basic map generator working by setting it to favour using old paths and quitting out of long tunnelling operations. I very rarely get a broken dungeon, but I can use Flash's bitmapData to floodFill from each room and verify the network is connected.

Demo with source code

Hey, this is neat! One question though, why does it sometimes make parallel corridors? Doesn't your system try to use existing corridors?  Also, what is stopping it from drilling a corridor directly from the corner of one room to the corner of another, ignoring all wall-pieces?

Nevertheless, the results are fantastic. I really need to get some foundations together for this sort of thing.
Logged

twitter: @docky
st33d
Guest
« Reply #24 on: October 13, 2009, 01:44:49 PM »

I pick random exits and entrances on each room and just try to drill from exit to entrance.

I tried drilling from exit to entrance straight and generally that looked awful, most of the rock got carved right out in the center. Then I remembered about the way you can make certain paths "expensive" to a search algorithm.

When the driller goes to select a new square a penalty is added to the distance of any previously visted square and to any untouched squares. Thus it tends to double back trying to use less energy, gets trapped, then digs out - or runs out of time.

I think the parallel routes and favouring of corners work well for my game with it being a platformer.

I'm now trying to figure out how to cover it all with ledges and ladders.  Crazy
« Last Edit: October 13, 2009, 01:50:00 PM by st33d » Logged
st33d
Guest
« Reply #25 on: October 14, 2009, 09:07:00 AM »

Had a break thru with the ladders:

Basically any point of no return in a platformer is a cliff.

A cliff is any L-shaped open space around a platform. To provide access throughout the whole level - we deal with the cliffs.

Code:
// count all the cliffs that are in the level. A cliff is an L-shaped area where the
// character can fall off

// first we get the bitmap as a vector, this makes iterating over it faster

var pixels:Vector.<uint> = map_bitmap.bitmapData.getVector(map_bitmap.bitmapData.rect);

var map_width:int = map_bitmap.bitmapData.width;

var cliffs:Vector.<Pixel> = new Vector.<Pixel>;

// there is a border around the map - we don't need to count it
for(i = map_width; i < pixels.length - map_width; i++){
if(i % map_width > 0 && i % map_width < map_width - 1){
if(pixels[i] == 0xFFFFFF00 && pixels[i - map_width] == 0xFFFFFF00){
// we have a gap, now we look for the cliffs
if(pixels[i - 1] == 0xFFFF0000 && pixels[i - 1 - map_width] == 0xFFFFFF00){
cliffs.push(new Pixel(i % map_width, i / map_width));
} else if(pixels[i + 1] == 0xFFFF0000 && pixels[(i + 1) - map_width] == 0xFFFFFF00){
cliffs.push(new Pixel(i % map_width, i / map_width));
}
}
}
}

for(i = 0; i < cliffs.length; i++){
map_bitmap.bitmapData.setPixel32(cliffs[i].x, cliffs[i].y, 0xFF00FF00);
}

I can now get to the stage of being able to explore my own dungeons!
Logged
Pages: 1 [2]
Print
Jump to:  

Theme orange-lt created by panic