128 lines
4.4 KiB
Plaintext
128 lines
4.4 KiB
Plaintext
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
|
"Proclib" definition
|
|
````````````````````````````````
|
|
This file describes our structure generation library - end-goal, wanted features, etc.
|
|
|
|
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
|
End-goal
|
|
````````````````
|
|
This library seeks to provide dynamic map generation for cell/grid based worlds. This is provided through structure-centric definition files thatare used to dynamically generate the world.
|
|
|
|
The library is implemented in C and can be compiled into a separate library (and header) or it can be built directly into the target program by adding and referencing the appropriate C source and header files.
|
|
|
|
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
|
Features
|
|
````````````````
|
|
This section provides a list of features implemented by the library.
|
|
,,,,,,,,,,,,,,,,
|
|
Structures(s), Section(s), and SectionRelation(s)
|
|
````````
|
|
At the core of the library is the Structure struct. A Structure is, as the name suggests, a stand-alone set of data that would generally represent something such as a house, a tower, etc.. Structures are at the core of any map generation and can be used to make most any set of cells (it can be used for room generation, floor path generation, and much more).
|
|
|
|
Code-wise, each Structure contains a dynamically sized array of pointers to other Structures(struct Structure **relations), a dynamically sized array of unsigned integers for the type of relationship(unsigned int **relation_flags), and a count of the current relationships held (size_t relation_count).
|
|
|
|
Structures also possess two unsigned int bitflags (id_1 and id_2) which is used for general purpose grouping and identification. Structures also possess the void pointer, data, and accompanying size_t data_size that may be used to store additional data. Note that data will not be free()'d unless the FREE_DATA flag is set in the Structure's flags bitflag.
|
|
|
|
In general, Structures are intended to be as abstract from specifics as much as possible, thereby allowing for a more flexible system.
|
|
,,,,,,,,,,,,,,,,
|
|
Structure Generation Syntax
|
|
````````
|
|
; name is the _unique_ name of the structure ("chest", "tower", "room", etc.)
|
|
name {
|
|
; flags may be: RELATIVE|WORLD for positioning and sizing settings
|
|
flags RELATIVE
|
|
; position data may be: unspecified, absolute(3), or a range(1-3)
|
|
; values may be: explicit(3), relative(-3,+3), or percentage(25%)
|
|
x 3
|
|
y 3
|
|
; size data may be: unspecified, absolute(3), or a range(1-3)
|
|
; values may be: explicit(3), relative(-3,+3), or percentage(25%)
|
|
size_x 1-8
|
|
size_y 1-9
|
|
; id data may be: unspecified, absolute, range, or a set of absolutes or ranges
|
|
id_1 1
|
|
id_2 10-11, 9, 13-14
|
|
; Structures
|
|
relations {
|
|
name {
|
|
; count is how many times to run
|
|
count 2
|
|
; flag may be CREATE or FIND, BORDER, EXTEND
|
|
flag CREATE|BORDER
|
|
; from/to logic is: if plain "name", it is in this context, if starting with ":name", it is in a global context. Each ":" signifies the depth to search, such as ":castle:room:door"
|
|
; from flags: UNIQUE - from structure must not already have a from operation.
|
|
; to flags: UNIQUE - find a structure that does not have a connection
|
|
; from references another Structure
|
|
from :name
|
|
from_flag UNIQUE
|
|
; to references another Structure
|
|
to :room:door
|
|
to_flag UNIQUE
|
|
; if from/to are set and pathing is set, specify the path Structure to use
|
|
path name
|
|
}
|
|
}
|
|
}
|
|
|
|
,,,,,,,,,,,,,,,,
|
|
Path -> House example
|
|
````````
|
|
;; define our basic structures
|
|
dirt_path {
|
|
size_x 1-3
|
|
size_y 1-3
|
|
id_1 1 ; "ground"
|
|
id_2 3 ; "dirt"
|
|
}
|
|
house_floor {
|
|
id_1 2 ; "floors"
|
|
id_2 2-4 ; "house tiles"
|
|
}
|
|
house_door {
|
|
id_1 4 ; "doors"
|
|
id_2 2 ; "house door"
|
|
}
|
|
house_walls {
|
|
id_1 3 ; "walls"
|
|
id_2 2-4 ; "house walls"
|
|
}
|
|
;; define a complex structure
|
|
house {
|
|
size_x 6-10
|
|
size_y 6-10
|
|
relations {
|
|
house_floor {
|
|
flags CREATE|CIRCLE|FILL
|
|
}
|
|
house_walls {
|
|
flags CREATE|CIRCLE|BORDER
|
|
}
|
|
house_doors {
|
|
flags CREATE|CIRCLE|BORDER|REPLACE
|
|
count 2
|
|
}
|
|
}
|
|
}
|
|
;; define a more complex structure!
|
|
map {
|
|
size_x 20
|
|
size_y 20
|
|
relations {
|
|
house {
|
|
flags CREATE
|
|
; place house in top-left randomly
|
|
x 1-10
|
|
y 1-10
|
|
}
|
|
dirt_path {
|
|
flags CREATE|UNIQUE
|
|
to house:house_door
|
|
to_flags UNIQUE ; create paths to both doors
|
|
count 2
|
|
; place paths in bottom-right randomly
|
|
x 15-20
|
|
y 15-20
|
|
}
|
|
}
|
|
}
|