-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dungeon generation #72
base: terra
Are you sure you want to change the base?
Conversation
dungeon generation now uses predefined upstairs positions
l->zone_info.zones[zone-1].size--; | ||
|
||
if (l->zone_info.zones[zone-1].size == 0) { | ||
// Should also update zone info map values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it kind of TODO?
/* | ||
* Populates zone info by floodfill-testing empty spaces. | ||
*/ | ||
void zone_test(level_t *l, int z) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most disgusting variable name, ever given by developer. 1+l.
y = rand() % l->h; | ||
if (AT(l, x, y, z) == '.') { | ||
AT(l, x, y, z) = (down ? '>' : '<'); | ||
return (coords_t){ x, y, z }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it standard defined method to construct an initialized structure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А точно есть в стандарте?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Есть, это compound literal, который появился в C99.
A postfix expression that consists of a parenthesized type name followed by a brace-enclosed list of initializers is a compound literal. It provides an unnamed object whose value is given by the initializer list.
} | ||
} | ||
|
||
char flag = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include stdbool...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Неа, true
и false
мы с тобой решили не использовать
* Returns an array of available dungeon generation parts. | ||
*/ | ||
dg_parts_array_t load_gen_parts() { | ||
dg_parts_array_t result = (dg_parts_array_t) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment about structures again
@@ -0,0 +1,27 @@ | |||
CC=gcc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Закомментить
Надо ещё добавить описание idp + то, как вызывать файл |
ssize_t rtm_size = l->w * l->h * sizeof(int); | ||
|
||
l->zone_info.count = 0; | ||
l->zone_info.map = realloc(l->zone_info.map, rtm_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check
for (int k = 0; k < l->d; ++k) { | ||
for (int j = 0; j < l->h; ++j ) { | ||
for (int i = 0; i < l->w; ++i) { | ||
if ((rand() % 100) > wall_rate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/rand()/random()
y = rand() % l->h; | ||
if (AT(l, x, y, z) == '.') { | ||
AT(l, x, y, z) = (down ? '>' : '<'); | ||
return (coords_t){ x, y, z }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А точно есть в стандарте?
* ret : 'pos' coordinates projected onto level | ||
*/ | ||
coords_t sm2l(coords_t pos, int w, int h, int d, dir_t dir) { | ||
(void)d; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут точно надо d?
* ret : resulting direction | ||
*/ | ||
static dir_t _get_conn_dir(dg_gen_part_t *t, dir_t dir, int conn) { | ||
int d; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Инициализировать
switch(p->dir) { | ||
case NORTH: | ||
// Does not fit into 80 chars sadly | ||
AT(l, p->pos.x+i, p->pos.y+j, p->pos.z+k) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В математических кругах за такое бьют
Generates a dungeon using supplied through stdin level info and upstairs positions (as arguments) from predefined and loaded dungeon pieces (all files in PIECES_DIR (./pieces/) ending in ".idp"). Outputs dungeon map into stdout.
Supports multi z-level dungeons, z-levels are separated by a single newline in both input/output.
Also includes very simple cave generator.