So I've been following the Minecraft thread for a couple days now, and there's a bunch of neat stuff going on. However, for the game I'm trying to make, I was thinking of something more along the lines of Dungeon Keeper levels. Specifically:
I was replaying DK1 and 2 and trying to figure out exactly how the level geometry worked. It seems to be generated from a couple of 2D arrays or grids. One grid for the base terrain type (ores, dirt block / open space, wall block, water, impenetrable rock, lava), one for room type (none, claimed floor, and one for each room type), and one for which faction the tile belongs to. The ceiling seems to be an upside-down height-map that automatically attaches to walls and un-attaches if you dig out the wall.
Walls are the most interesting, because each side changes according to the tiles next to it. You can have a wall block that displays up to four different room-styles by plunking down four different room tiles next to one wall tile. I know you can SetObjectImage to change all of a box's faces at once, but is there a way to change each face independently?
In DK1 most of the props are billboard sprites, but in DK2 they're all 3D models. They seem to mostly be static meshes, though some of them rotate.
Anyway, what I'd like to do is something kind of like
Delver. But Delver has a completely separate level editor, and I kind of want the dynamic levels of DK. Delver also has large, detailed rooms that are fine individually but get same-y if you play long enough, and I'd like to have something a bit more rogue-ish (or, to keep things on topic, obviously Dungeon Keeper does this as well) where the functions of the rooms are similar but the dimensions and precise layout vary wildly. Maybe I should have called this post "Dungeon Keeper / Delver style levels".
You want source code?
My source code? For some reason? All right, but it's not very pretty right now:
//define the block type
type block
blockType as integer
objectIndex as integer
endtype
//define the 3D array for the blocks
blockArray as block [LEVEL_WIDTH, LEVEL_HEIGHT, LEVEL_LENGTH]
//set all the blockTypes blank "air" by default
for x = 0 to LEVEL_WIDTH
for y = 0 to LEVEL_HEIGHT
for z = 0 to LEVEL_LENGTH
blockArray[x, y, z].blockType = BT_AIR
next z
next y
next x
//except for a bunch we want to test
for x = 0 to LEVEL_WIDTH
//for y = 0 to LEVEL_HEIGHT
for z = 0 to LEVEL_LENGTH
blockArray[x, 0, z].blockType = BT_STONE
next z
//next y
next x
//for x = 0 to LEVEL_WIDTH
for y = 1 to 7
//for z = 0 to LEVEL_LENGTH
blockArray[0, y, 1].blockType = BT_STONE
//next z
next y
//next x
//for x = 0 to LEVEL_WIDTH
for y = 1 to 7
//for z = 0 to LEVEL_LENGTH
blockArray[5, y, 1].blockType = BT_STONE
//next z
next y
//next x
for x = 0 to 5
//for y = 1 to 5
//for z = 0 to LEVEL_LENGTH
blockArray[x, 7, 1].blockType = BT_STONE
//next z
//next y
next x
//blockArray[0, 0, 0].blockType = BT_AIR
blockArray[LEVEL_WIDTH, LEVEL_HEIGHT, LEVEL_LENGTH].blockType = BT_STONE
//make the blocks according to the array
for x = 0 to LEVEL_WIDTH
for y = 0 to LEVEL_HEIGHT
for z = 0 to LEVEL_LENGTH
if blockArray[x, y, z].blockType <> BT_AIR
//automatically, not manually, create the blocks from the array
blockArray[x, y, z].objectIndex = CreateObjectBox(BLOCK_WIDTH, BLOCK_WIDTH, BLOCK_WIDTH) //(x*LEVEL_WIDTH*LEVEL_HEIGHT)+(y*LEVEL_HEIGHT)+z+1
SetObjectPosition(blockArray[x, y, z].objectIndex, x * BLOCK_WIDTH, y * BLOCK_WIDTH, z * BLOCK_WIDTH)
SetObjectColor(blockArray[x, y, z].objectIndex, random(0, 255), random(0, 255), random(0, 255), 255)
endif
next z
next y
next x
So far, I have a 3D array which has data for blocks, and a function that creates randomly colored boxes according to each position in the array. (If "WASD or joystick to move" looks familiar, that's because I borrowed the camera controls from the FPS Example project. It's just a placeholder) I don't need infinite terrain, in fact I'm thinking more along the lines of "cozy" corridors and rooms for now with maybe overland or more exotic locations later.