diff --git a/docs/requirements.md b/docs/requirements.md index 2f47f2b..571a74d 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -28,7 +28,7 @@ Output port indicators are not building tiles themselves. A building may have mo ## Game World - REQ-GW-COORDS: Tile coordinates are integer `(x, y)`. The origin `(0, 0)` is the first column of space — the tile immediately to the right of the asteroid's right edge at game start, at the top of the world. X grows right; Y grows down. All asteroid tiles have `x < 0`; asteroid left-expansions add tiles at increasingly negative X. The origin never shifts. -- REQ-GW-TILE-SIZE: Tiles are 20×20 pixels. Items on belts are 10×10 pixels (half a tile), so each belt tile holds at most 2 items. +- REQ-GW-TILE-SIZE: Tiles are square. The tile size in pixels is derived automatically so that the world height (in tiles) exactly fills the game world view's height in pixels. Items on belts are rendered at half-tile size, so each belt tile holds at most 2 items. - REQ-GW-BELT-SPEED: Items on belts move at `world.toml [world].belt_speed_tiles_per_second` tiles per second (default 2). - REQ-GW-HEIGHT: The world height (in tiles) is read from `world.toml [world].height_tiles`. - REQ-GW-REGIONS: The world is divided into horizontal regions whose widths (in tiles) are read from `world.toml [regions]`: diff --git a/src/ui/GameWorldView.cpp b/src/ui/GameWorldView.cpp index 7d371d7..4e8dab8 100644 --- a/src/ui/GameWorldView.cpp +++ b/src/ui/GameWorldView.cpp @@ -243,7 +243,8 @@ void GameWorldView::paintGL() float GameWorldView::tilePx() const { - return 20.0f; + if (m_config->world.heightTiles <= 0) { return 1.0f; } + return static_cast(height()) / static_cast(m_config->world.heightTiles); } float GameWorldView::viewportWidthTiles() const