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.
// 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!