From ec20778215dbc4605316ad8d3643d11442aa3215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Wisniewski?= Date: Wed, 2 Sep 2026 11:19:54 +0200 Subject: [PATCH] Enlarge mobile joystick controls --- surface/PlanetSurface.tscn | 8 ++++---- tests/test_joystick_recentres.gd | 28 ++++++++++++++++++++++++++-- ui/TouchJoystick.gd | 5 ++++- world/Main.tscn | 24 ++++++++++++------------ 4 files changed, 46 insertions(+), 19 deletions(-) diff --git a/surface/PlanetSurface.tscn b/surface/PlanetSurface.tscn index ebb53d5..678d079 100644 --- a/surface/PlanetSurface.tscn +++ b/surface/PlanetSurface.tscn @@ -147,8 +147,8 @@ core_color = Color(0.02, 0.09, 0.15, 1) anchor_top = 1.0 anchor_bottom = 1.0 offset_left = 12 -offset_right = 252 -offset_top = -330 +offset_right = 492 +offset_top = -430 offset_bottom = -80 [node name="FireStick" type="Control" parent="UI"] @@ -160,9 +160,9 @@ anchor_left = 1.0 anchor_right = 1.0 anchor_top = 1.0 anchor_bottom = 1.0 -offset_left = -252 +offset_left = -492 offset_right = -12 -offset_top = -330 +offset_top = -430 offset_bottom = -80 [node name="SpeedFader" type="Control" parent="UI"] diff --git a/tests/test_joystick_recentres.gd b/tests/test_joystick_recentres.gd index d997263..a2b7695 100644 --- a/tests/test_joystick_recentres.gd +++ b/tests/test_joystick_recentres.gd @@ -17,6 +17,8 @@ extends SceneTree # on a stick nobody is holding const OFFSET := Vector2(-58.0, 41.0) +const MIN_TOUCH_AREA: float = 160000.0 +const MIN_VISIBLE_RADIUS: float = 138.0 var main: Node var stage: int = 0 @@ -31,6 +33,11 @@ func _initialize() -> void: func _check(stick: Control, label: String) -> bool: var home: Vector2 = stick.home_pos() + if stick.size.x * stick.size.y < MIN_TOUCH_AREA: + return _fail("%s touch zone is only %s (%.0f area)" \ + % [label, stick.size, stick.size.x * stick.size.y]) + if stick.max_radius < MIN_VISIBLE_RADIUS: + return _fail("%s visible radius is only %.0f" % [label, stick.max_radius]) # --- A. idle means centred ------------------------------------------- if stick.base_pos.distance_to(home) > 0.01 or stick.knob_pos.distance_to(home) > 0.01: @@ -77,6 +84,18 @@ func _check(stick: Control, label: String) -> bool: return true +func _check_pair(host: Node, label: String) -> bool: + var movement: Control = host.get_node("UI/Joystick") + var fire: Control = host.get_node("UI/FireStick") + if movement.get_global_rect().intersects(fire.get_global_rect()): + return _fail("%s joystick touch zones overlap" % label) + if not _check(movement, "%s movement stick" % label): + return false + if not _check(fire, "%s fire stick" % label): + return false + return true + + func _process(delta: float) -> bool: elapsed += delta if stage != 0: @@ -84,10 +103,15 @@ func _process(delta: float) -> bool: if elapsed < 0.2: return false stage = 1 - if not _check(main.get_node("UI/Joystick"), "movement stick"): + if not _check_pair(main, "space"): return true - if not _check(main.get_node("UI/FireStick"), "fire stick"): + var surface: Node = load("res://surface/PlanetSurface.tscn").instantiate() + root.add_child(surface) + if not _check_pair(surface, "surface"): return true + surface.queue_free() + print("both scenes provide non-overlapping 480x350 zones with %.0f-radius rings" \ + % main.get_node("UI/Joystick").max_radius) print("TEST_JOYSTICK_RECENTRES: PASS") quit(0) return true diff --git a/ui/TouchJoystick.gd b/ui/TouchJoystick.gd index 5685f91..82ee19b 100644 --- a/ui/TouchJoystick.gd +++ b/ui/TouchJoystick.gd @@ -23,7 +23,10 @@ signal released # shorter side. Derived rather than a fixed number of pixels so that # enlarging the stick's rect enlarges the ring the player actually sees - # otherwise the touch area grows and the visible control stays small. -const RADIUS_RATIO: float = 0.28 +# The scene zones are deliberately wider than they are tall. Forty percent +# makes the resting ring just over twice its former radius while leaving room +# for the floating base to move inside the touch rect. +const RADIUS_RATIO: float = 0.40 @export var max_radius: float = 90.0 @export var deadzone: float = 0.12 diff --git a/world/Main.tscn b/world/Main.tscn index 63bd37d..8a1a2ef 100644 --- a/world/Main.tscn +++ b/world/Main.tscn @@ -285,8 +285,8 @@ script = ExtResource("13") anchor_top = 1.0 anchor_bottom = 1.0 offset_left = 12 -offset_right = 252 -offset_top = -330 +offset_right = 492 +offset_top = -430 offset_bottom = -80 [node name="FireStick" type="Control" parent="UI"] @@ -298,9 +298,9 @@ anchor_left = 1.0 anchor_right = 1.0 anchor_top = 1.0 anchor_bottom = 1.0 -offset_left = -252 +offset_left = -492 offset_right = -12 -offset_top = -330 +offset_top = -430 offset_bottom = -80 [node name="SpeedFader" type="Control" parent="UI"] @@ -340,8 +340,8 @@ anchor_top = 1.0 anchor_bottom = 1.0 offset_left = -196 offset_right = -100 -offset_top = -492 -offset_bottom = -396 +offset_top = -548 +offset_bottom = -452 [node name="PivotCCWButton" type="Control" parent="UI"] mouse_filter = 2 @@ -352,8 +352,8 @@ anchor_left = 1.0 anchor_right = 1.0 anchor_top = 1.0 anchor_bottom = 1.0 -offset_left = -468 -offset_right = -364 +offset_left = -620 +offset_right = -516 offset_top = -130 offset_bottom = -26 @@ -370,8 +370,8 @@ anchor_top = 1.0 anchor_bottom = 1.0 offset_left = -324 offset_right = -228 -offset_top = -424 -offset_bottom = -328 +offset_top = -548 +offset_bottom = -452 [node name="GasBombStatus" type="Label" parent="UI"] mouse_filter = 2 @@ -414,8 +414,8 @@ anchor_left = 1.0 anchor_right = 1.0 anchor_top = 1.0 anchor_bottom = 1.0 -offset_left = -356 -offset_right = -252 +offset_left = -508 +offset_right = -404 offset_top = -130 offset_bottom = -26