Unit cave
Classes, Interfaces, Objects and Records
Description
Generate a cave using two passes of a cellular automata algorithm and then remove any unreachable areas by floodfilling the map and discarding maps that are less than 39% floor tiles. Stairs are placed on the top level and a connecting stairway is placed on the floor below. If the floor below has a wall tile where the stair should be, that floor is discarded and generated again.
Uses
- SysUtils
- globalutils
- Classes
Overview
Functions and Procedures
procedure fillWithWalls; |
procedure randomTileFill; |
procedure digCave(floorNumber: byte); |
procedure generate(title: string; idNumber: smallint; totalDepth: byte); |
function blockORnot(x, y: integer): Tbkinds; |
procedure calcDistances(x, y: smallint); |
function leftHasFloor(): boolean; |
function rightHasFloor(): boolean; |
Types
Tbkinds = (...); |
TDist = array [1..MAXROWS, 1..MAXCOLUMNS] of integer; |
Constants
BLOCKVALUE = 99; |
Variables
c: smallint; |
distances: TDist; |
i: smallint; |
iterations: smallint; |
r: smallint; |
stairX: smallint; |
stairY: smallint; |
tempArray: array[1..MAXROWS, 1..MAXCOLUMNS] of shortstring; |
tempArray2: array[1..MAXROWS, 1..MAXCOLUMNS] of shortstring; |
terrainArray: array[1..MAXROWS, 1..MAXCOLUMNS] of shortstring; |
tileCounter: smallint; |
totalRooms: byte; |
Description
Functions and Procedures
procedure fillWithWalls; |
Fill array with walls |
procedure randomTileFill; |
Fill array with random tiles |
procedure digCave(floorNumber: byte); |
Dig out the cave |
procedure generate(title: string; idNumber: smallint; totalDepth: byte); |
Generate a caves and place the stairs |
function blockORnot(x, y: integer): Tbkinds; |
Determines if a tile is a wall or not |
procedure calcDistances(x, y: smallint); |
Floodfill cave to find unreachable areas |
function leftHasFloor(): boolean; |
Check that the left side of the map contains floor tiles |
function rightHasFloor(): boolean; |
Check that the right side of the map contains floor tiles |
Types
Tbkinds = (...); |
Values
|
TDist = array [1..MAXROWS, 1..MAXCOLUMNS] of integer; |
Constants
BLOCKVALUE = 99; |
Variables
c: smallint; |
distances: TDist; |
i: smallint; |
iterations: smallint; |
r: smallint; |
stairX: smallint; |
stairY: smallint; |
tempArray: array[1..MAXROWS, 1..MAXCOLUMNS] of shortstring; |
tempArray2: array[1..MAXROWS, 1..MAXCOLUMNS] of shortstring; |
terrainArray: array[1..MAXROWS, 1..MAXCOLUMNS] of shortstring; |
tileCounter: smallint; |
totalRooms: byte; |
Generated by PasDoc 0.16.0.