Allow moving past the top-left edge of the world.

This commit is contained in:
King_DuckZ 2016-11-04 20:31:41 +01:00
parent d7868800d4
commit 1313dad568

View file

@ -2,6 +2,7 @@
#include "worldgrid.hpp"
#include "compatibility.h"
#include <cassert>
#include <algorithm>
namespace curry {
namespace {
@ -11,8 +12,8 @@ namespace curry {
const auto pos = vector_cast<vec2i>(parViewport.position());
const auto ts = parViewport.world()->tile_size();
return vec2us(
static_cast<uint16_t>(pos.x() / ts.x()),
static_cast<uint16_t>(pos.y() / ts.y())
static_cast<uint16_t>(std::max(0, pos.x()) / ts.x()),
static_cast<uint16_t>(std::max(0, pos.y()) / ts.y())
);
}
} //unnamed namespace