const int MAP_MIN_PIXEL_X = 0;
const int MAP_MAX_PIXEL_X = MAP_PIXELS_X - 1;
+const int MAP_MIN_PIXEL_Y = 0;
+const int MAP_MAX_PIXEL_Y = MAX_TILES_PER_SIDE * TILE_SIZE_Y - 1;
+
const double MAP_SCENE_VERTICAL_OVERSIZE_FACTOR = 0.5;
const int MAP_SCENE_MIN_PIXEL_X = -MAP_PIXELS_X * MAP_SCENE_VERTICAL_OVERSIZE_FACTOR;
const int MAP_SCENE_MAX_PIXEL_X = MAP_PIXELS_X * (1 + MAP_SCENE_VERTICAL_OVERSIZE_FACTOR) - 1;
{
qDebug() << __PRETTY_FUNCTION__;
- // jump to opposite side of the world if world limit is exceeded
+ // jump to opposite side of the world if world horizontal limit is exceeded
if (sceneCoordinate.x() < MAP_MIN_PIXEL_X)
sceneCoordinate.setX(sceneCoordinate.x() + MAP_PIXELS_X);
else if (sceneCoordinate.x() > MAP_MAX_PIXEL_X)
sceneCoordinate.setX(sceneCoordinate.x() - MAP_PIXELS_X);
+ // don't allow vertical scene coordinates go out of the map
+ sceneCoordinate.setY(qBound(MAP_MIN_PIXEL_Y, sceneCoordinate.y(), MAP_MAX_PIXEL_Y));
+
if (disableAutoCentering(sceneCoordinate))
emit mapScrolledManually();
#include "mapscene.h"
-const int MAP_MIN_PIXEL_Y = 0;
-const int MAP_MAX_PIXEL_Y = MAX_TILES_PER_SIDE * TILE_SIZE_Y - 1;
-
MapScene::MapScene(QObject *parent)
: QGraphicsScene(parent)
, m_isRemoveStackedTilesRunning(false)