summaryrefslogtreecommitdiff
path: root/src/gui/viewport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r--src/gui/viewport.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 5f316aea..bc635cce 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -132,18 +132,22 @@ Viewport::draw(gcn::Graphics *gcnGraphics)
mViewY = player_y;
};
- if (mMap) {
+ // Don't move camera so that the end of the map is on screen
+ int viewXmax = mMap->getWidth() * 32 - graphics->getWidth();
+ int viewYmax = mMap->getHeight() * 32 - graphics->getHeight();
+ if (mMap)
+ {
if (mViewX < 0) {
mViewX = 0;
}
if (mViewY < 0) {
mViewY = 0;
}
- if (mViewX > mMap->getWidth() * 32 - midTileX) {
- mViewX = mMap->getWidth() * 32 - midTileX;
+ if (mViewX > viewXmax) {
+ mViewX = viewXmax;
}
- if (mViewY > mMap->getHeight() * 32 - midTileY) {
- mViewY = mMap->getHeight() * 32 - midTileY;
+ if (mViewY > viewYmax) {
+ mViewY = viewYmax;
}
}