Fixed rooms not always being connected.

This commit is contained in:
Felix Ableitner 2013-09-02 19:20:01 +02:00
parent 8c5d3a32cf
commit 2f3ed4b14d
3 changed files with 4 additions and 8 deletions

View File

@ -141,12 +141,10 @@ World::draw(sf::RenderTarget& target, sf::RenderStates states) const {
sf::FloatRect screen(target.getViewport(target.getView()));
screen.left += target.getView().getCenter().x - target.getView().getSize().x / 2;
screen.top += target.getView().getCenter().y - target.getView().getSize().y / 2;
for (auto v = mDrawables.begin(); v != mDrawables.end(); v++) {
for (const auto& item : v->second) {
for (auto v = mDrawables.begin(); v != mDrawables.end(); v++)
for (const auto& item : v->second)
if (item->isInside(screen))
target.draw(static_cast<sf::Drawable&>(*item), states);
}
}
}
/*

View File

@ -19,7 +19,6 @@
#include "../Pathfinder.h"
#include "../World.h"
#include "../sprites/Enemy.h"
#include "../util/Log.h"
/**
* Generates new random seed.
@ -159,7 +158,7 @@ Generator::connectRooms(const Vector2i& start) {
destinations.insert(current);
break;
}
else if (distance.at(current) < ROOM_CONNECTION_VALUE) {
if (distance.at(current) < ROOM_CONNECTION_VALUE) {
process(Vector2i(current.x + 1, current.y), current);
process(Vector2i(current.x, current.y + 1), current);
process(Vector2i(current.x - 1, current.y), current);
@ -167,7 +166,6 @@ Generator::connectRooms(const Vector2i& start) {
}
}
// take min length paths and set tiles
float totalValue = 0.0f;
while (totalValue < ROOM_CONNECTION_VALUE && !destinations.empty()) {
std::vector<Vector2i> path;

View File

@ -44,7 +44,7 @@ private:
private:
static constexpr int GENERATE_AREA_SIZE = 4;
static constexpr float GENERATE_AREA_RANGE = 4.0f;
static constexpr float ROOM_SIZE_VALUE = 12.0f;
static constexpr float ROOM_SIZE_VALUE = 10.0f;
static constexpr float ROOM_CONNECTION_VALUE = 5.0f;
World& mWorld;