Redefine camera scroll as view center

This commit is contained in:
2026-07-13 21:31:52 +02:00
parent 535d4f8f24
commit 80a2622267
2 changed files with 20 additions and 8 deletions

View File

@@ -134,6 +134,9 @@ private:
float tilePx() const;
float viewportWidthTiles() const;
// World-X (tiles) at the left edge of the viewport. m_scrollXTiles stores the
// view center; this derives the left edge the world<->widget conversions need.
float viewLeftTiles() const;
QPointF worldToWidget(QVector2D worldPos) const;
QPointF tileToWidget(QPoint tile) const;
QPoint widgetToTile(QPoint widgetPt) const;
@@ -218,6 +221,7 @@ private:
std::mt19937 m_rng;
double m_gameSpeedMultiplier;
double m_prevNonZeroSpeed;
// World-X (tiles) at the center of the viewport (see viewLeftTiles()).
float m_scrollXTiles;
QTimer* m_renderTimer;