Aim the laser by depth, and ease the aim view

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AJMdB7iuHuLFZM1aBu3GD
This commit is contained in:
Loïc Wisniewski 2026-09-05 09:32:42 +02:00
commit 2239235993
5 changed files with 123 additions and 28 deletions

View file

@ -46,12 +46,26 @@ func _ready() -> void:
press.position = button.global_position + button.size * 0.5
press.pressed = true
skill.handle_touch(press)
var drag := InputEventScreenDrag.new()
drag.index = 9
drag.position = press.position + Vector2(-245.0, -235.0)
skill.handle_drag(drag)
for t in [0.35, 0.6]:
# Enemies BEFORE the drag, so the aim helper actually sees them. A nearer
# one on the heading and a further one just off it: the state this preview
# exists to show is the drag reaching past the first to name the second.
var heading: Vector2 = Vector2(-245.0, -235.0).normalized()
var reach: float = skill._aim_max_range()
var origin: Vector2 = fleet.get_centroid()
var far_offset: Vector2 = heading.rotated(deg_to_rad(8.0)) * 1900.0
for offset in [heading * 900.0, far_offset]:
var enemy: Node = load("res://enemies/Enemy.tscn").instantiate()
enemy.position = fleet.get_centroid().lerp(skill.aim_target, t)
enemy.position = origin + offset
main.add_child(enemy)
enemy.speed = 0.0 # after add_child - _ready() sets it from the definition
var drag := InputEventScreenDrag.new()
drag.index = 9
# Dragged out to the further enemy's depth rather than to the beam's end.
drag.position = press.position + far_offset.normalized() \
* (1900.0 / reach * LaserController.DRAG_RADIUS)
skill.handle_drag(drag)
# The zoom eases now, so a preview that captures the first frame would
# catch it mid-move. Settle it before the screenshot is taken.
for _step in range(40):
skill._process(0.05)