World builder does a better job of placing entities in rooms and not walls.
This commit is contained in:
parent
03c5546cdf
commit
8d661b785b
2 changed files with 7 additions and 3 deletions
4
map.cpp
4
map.cpp
|
@ -48,8 +48,8 @@ Point Map::place_entity(size_t room_index) {
|
||||||
dbc::check(room_index < $rooms.size(), "room_index is out of bounds, not enough rooms");
|
dbc::check(room_index < $rooms.size(), "room_index is out of bounds, not enough rooms");
|
||||||
|
|
||||||
Room &start = $rooms[room_index];
|
Room &start = $rooms[room_index];
|
||||||
// BUG: this can place someone in a wall on accident, move them if they're stuck
|
|
||||||
return {start.x+1, start.y+1};
|
return {start.x+start.width/2, start.y+start.height/2};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Map::iswall(size_t x, size_t y) {
|
bool Map::iswall(size_t x, size_t y) {
|
||||||
|
|
|
@ -160,7 +160,11 @@ void WorldBuilder::generate() {
|
||||||
for(size_t i = 0; i < $map.$rooms.size() - 1; i++) {
|
for(size_t i = 0; i < $map.$rooms.size() - 1; i++) {
|
||||||
size_t room_type = Random::uniform<size_t>(0, room_types.size() - 1);
|
size_t room_type = Random::uniform<size_t>(0, room_types.size() - 1);
|
||||||
int room_size = Random::uniform<int>(100, 800);
|
int room_size = Random::uniform<int>(100, 800);
|
||||||
stylize_room(i, room_types[room_type], room_size * 0.01f);
|
string tile_name = room_types[room_type];
|
||||||
|
// BUG: really tiles should be configured as collision or not
|
||||||
|
if(tile_name != "WALL_TILE") {
|
||||||
|
stylize_room(i, tile_name, room_size * 0.01f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue