Some jank test visual effects are working.
This commit is contained in:
parent
243d15c123
commit
f9bf8f06ea
4 changed files with 66 additions and 18 deletions
23
map.cpp
23
map.cpp
|
@ -2,11 +2,9 @@
|
|||
#include "dbc.hpp"
|
||||
#include <vector>
|
||||
#include <fmt/core.h>
|
||||
#include <random>
|
||||
#include "rand.hpp"
|
||||
#include <utility>
|
||||
|
||||
std::random_device $RNG;
|
||||
std::mt19937 $GENERATOR($RNG());
|
||||
|
||||
using std::vector, std::pair;
|
||||
using namespace fmt;
|
||||
|
@ -116,8 +114,8 @@ inline int make_split(Room &cur, bool horiz) {
|
|||
size_t dimension = horiz ? cur.height : cur.width;
|
||||
int min = dimension / 4;
|
||||
int max = dimension - min;
|
||||
std::uniform_int_distribution<int> rand_dim(min, max);
|
||||
return rand_dim($GENERATOR);
|
||||
|
||||
return Random::rand_int(min, max);
|
||||
}
|
||||
|
||||
void Map::partition_map(Room &cur, int depth) {
|
||||
|
@ -212,26 +210,25 @@ void Map::set_door(Room &room, int value) {
|
|||
}
|
||||
|
||||
void rand_side(Room &room, Point &door) {
|
||||
std::uniform_int_distribution<int> rand_side(0, 3);
|
||||
std::uniform_int_distribution<int> rand_x(0, room.width - 1);
|
||||
std::uniform_int_distribution<int> rand_y(0, room.height - 1);
|
||||
int rand_x = Random::rand_int(0, room.width - 1);
|
||||
int rand_y = Random::rand_int(0, room.height - 1);
|
||||
|
||||
switch(rand_side($GENERATOR)) {
|
||||
switch(Random::rand_int(0,3)) {
|
||||
case 0: // north
|
||||
door.x = room.x + rand_x($GENERATOR);
|
||||
door.x = room.x + rand_x;
|
||||
door.y = room.y-1;
|
||||
break;
|
||||
case 1: // south
|
||||
door.x = room.x + rand_x($GENERATOR);
|
||||
door.x = room.x + rand_x;
|
||||
door.y = room.y + room.height;
|
||||
break;
|
||||
case 2: // east
|
||||
door.x = room.x + room.width;
|
||||
door.y = room.y + rand_y($GENERATOR);
|
||||
door.y = room.y + rand_y;
|
||||
break;
|
||||
case 3: // west
|
||||
door.x = room.x - 1;
|
||||
door.y = room.y + rand_y($GENERATOR);
|
||||
door.y = room.y + rand_y;
|
||||
break;
|
||||
default:
|
||||
dbc::sentinel("impossible side");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue