Allow moving past the top-left edge of the world.
This commit is contained in:
parent
d7868800d4
commit
1313dad568
1 changed files with 3 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
||||||
#include "worldgrid.hpp"
|
#include "worldgrid.hpp"
|
||||||
#include "compatibility.h"
|
#include "compatibility.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace curry {
|
namespace curry {
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -11,8 +12,8 @@ namespace curry {
|
||||||
const auto pos = vector_cast<vec2i>(parViewport.position());
|
const auto pos = vector_cast<vec2i>(parViewport.position());
|
||||||
const auto ts = parViewport.world()->tile_size();
|
const auto ts = parViewport.world()->tile_size();
|
||||||
return vec2us(
|
return vec2us(
|
||||||
static_cast<uint16_t>(pos.x() / ts.x()),
|
static_cast<uint16_t>(std::max(0, pos.x()) / ts.x()),
|
||||||
static_cast<uint16_t>(pos.y() / ts.y())
|
static_cast<uint16_t>(std::max(0, pos.y()) / ts.y())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} //unnamed namespace
|
} //unnamed namespace
|
||||||
|
|
Loading…
Reference in a new issue