Just wrote my own entity system to figure it out.
This commit is contained in:
parent
a3eaf78fd3
commit
cc4f83a1d1
8 changed files with 229 additions and 59 deletions
11
map.cpp
11
map.cpp
|
@ -115,7 +115,7 @@ inline int make_split(Room &cur, bool horiz) {
|
|||
int min = dimension / 4;
|
||||
int max = dimension - min;
|
||||
|
||||
return Random::rand_int(min, max);
|
||||
return Random::uniform<int>(min, max);
|
||||
}
|
||||
|
||||
void Map::partition_map(Room &cur, int depth) {
|
||||
|
@ -125,7 +125,6 @@ void Map::partition_map(Room &cur, int depth) {
|
|||
return;
|
||||
}
|
||||
|
||||
std::uniform_int_distribution<int> rsplit(0, 1);
|
||||
bool horiz = cur.width > cur.height ? false : true;
|
||||
int split = make_split(cur, horiz);
|
||||
Room left = cur;
|
||||
|
@ -210,10 +209,10 @@ void Map::set_door(Room &room, int value) {
|
|||
}
|
||||
|
||||
void rand_side(Room &room, Point &door) {
|
||||
int rand_x = Random::rand_int(0, room.width - 1);
|
||||
int rand_y = Random::rand_int(0, room.height - 1);
|
||||
int rand_x = Random::uniform<int>(0, room.width - 1);
|
||||
int rand_y = Random::uniform<int>(0, room.height - 1);
|
||||
|
||||
switch(Random::rand_int(0,3)) {
|
||||
switch(Random::uniform<int>(0,3)) {
|
||||
case 0: // north
|
||||
door.x = room.x + rand_x;
|
||||
door.y = room.y-1;
|
||||
|
@ -306,7 +305,7 @@ void Map::generate() {
|
|||
println("ROOM NOT FOUND!");
|
||||
}
|
||||
clear_target(target.entry);
|
||||
}
|
||||
}
|
||||
|
||||
Room &src = $rooms.back();
|
||||
Room &target = $rooms.front();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue