feat(@projects/@magic-civilization): ✨ add zoom mode support for demo camera
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
00b157ecfc
commit
678a588bc5
1 changed files with 10 additions and 1 deletions
|
|
@ -125,12 +125,21 @@ func _ready() -> void:
|
|||
max_p = max_p.max(p)
|
||||
var bbox: Vector2 = max_p - min_p
|
||||
var center: Vector2 = (min_p + max_p) * 0.5
|
||||
# Fit the longer axis into the viewport with 5% padding.
|
||||
# `DEMO_ZOOM_MODE` env: "fit" (whole map, default) or "capital" (zoomed
|
||||
# to player-1's start hex so unit + city sprites are clearly visible).
|
||||
var mode: String = OS.get_environment("DEMO_ZOOM_MODE")
|
||||
if mode == "" :
|
||||
mode = "fit"
|
||||
var pad: float = 1.10
|
||||
var fit_x: float = (bbox.x * pad) / float(VIEWPORT_SIZE.x)
|
||||
var fit_y: float = (bbox.y * pad) / float(VIEWPORT_SIZE.y)
|
||||
var world_per_screen: float = max(fit_x, fit_y)
|
||||
var zoom_factor: float = 1.0 / max(world_per_screen, 0.001)
|
||||
if mode == "capital" and game_map.start_positions.size() > 0:
|
||||
var p1_axial: Vector2i = game_map.start_positions[0]
|
||||
center = HexUtilsScript.axial_to_pixel(p1_axial)
|
||||
# 9-tile wide window around the capital.
|
||||
zoom_factor = float(VIEWPORT_SIZE.x) / (9.0 * 384.0)
|
||||
var cam: Camera2D = Camera2D.new()
|
||||
cam.name = "DemoCamera"
|
||||
cam.position = center
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue