From 1313dad568829cb1fa1cafbf36e784d7a2271483 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 4 Nov 2016 20:31:41 +0100 Subject: [PATCH] Allow moving past the top-left edge of the world. --- src/worldviewport.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/worldviewport.cpp b/src/worldviewport.cpp index 99f57ce..9b72e61 100644 --- a/src/worldviewport.cpp +++ b/src/worldviewport.cpp @@ -2,6 +2,7 @@ #include "worldgrid.hpp" #include "compatibility.h" #include +#include namespace curry { namespace { @@ -11,8 +12,8 @@ namespace curry { const auto pos = vector_cast(parViewport.position()); const auto ts = parViewport.world()->tile_size(); return vec2us( - static_cast(pos.x() / ts.x()), - static_cast(pos.y() / ts.y()) + static_cast(std::max(0, pos.x()) / ts.x()), + static_cast(std::max(0, pos.y()) / ts.y()) ); } } //unnamed namespace