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:
parent
a902fddba0
commit
2239235993
5 changed files with 123 additions and 28 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -120,6 +120,12 @@ func _process(delta: float) -> bool:
|
|||
drag.index = 7
|
||||
drag.position = Vector2(350, 700)
|
||||
main._handle_drag(drag)
|
||||
# The aim view eases to its framing now instead of cutting to it,
|
||||
# so the drag alone has not moved the camera yet.
|
||||
if not is_equal_approx(main.get_node("Camera2D").zoom.x, original_zoom):
|
||||
return _fail_now("the aim zoom jumped instead of easing")
|
||||
for _step in range(40):
|
||||
skill._process(0.05)
|
||||
if main.get_node("Camera2D").zoom.x >= original_zoom:
|
||||
return _fail_now("long aim did not zoom out")
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ var skill: Node
|
|||
# in a test script has been observed to corrupt method resolution for the
|
||||
# WHOLE script. See tests/test_gas_bomber_cooldowns.gd's identical fix (#60).
|
||||
const BEAM_HALF_WIDTH: float = 38.0
|
||||
# Mirrored for the same reason, and it bites exactly as documented: a bare
|
||||
# DRAG_RADIUS here made every method call in this script
|
||||
# resolve against a plain Node2D.
|
||||
const DRAG_RADIUS: float = 260.0
|
||||
var on_line_enemies: Array = []
|
||||
var off_line_enemy: Node
|
||||
var beyond_range_enemy: Node
|
||||
|
|
@ -120,20 +124,28 @@ func _process(delta: float) -> bool:
|
|||
drag.index = 7
|
||||
drag.position = press.position + Vector2(300.0, 0.0)
|
||||
main._handle_drag(drag)
|
||||
# The aim view eases to its framing rather than cutting to it, so
|
||||
# the drag alone has not moved the camera yet.
|
||||
if not is_equal_approx(main.get_node("Camera2D").zoom.x, original_zoom):
|
||||
return _fail_now("the aim zoom jumped instead of easing")
|
||||
for _step in range(40):
|
||||
skill._process(0.05)
|
||||
if main.get_node("Camera2D").zoom.x >= original_zoom:
|
||||
return _fail_now("aiming did not zoom out")
|
||||
print("aiming zoomed the camera out")
|
||||
print("aiming eased the camera out instead of cutting to it")
|
||||
|
||||
# #203: far enough out to show the WHOLE beam. The drag above is
|
||||
# horizontal, so the screen's narrow half is the binding one.
|
||||
# #203: framed to twice the distance of the chosen target, so what
|
||||
# stands behind it is on screen too. The drag above is horizontal,
|
||||
# so the screen's narrow half is the binding one.
|
||||
var half_screen: Vector2 = skill.get_viewport_rect().size * 0.5 \
|
||||
- Vector2(54.0, 54.0)
|
||||
var framed: float = (2900.0 + BEAM_HALF_WIDTH) \
|
||||
var aimed_distance: float = skill._aim_origin().distance_to(skill.aim_target)
|
||||
var framed: float = (aimed_distance * 2.0 + BEAM_HALF_WIDTH) \
|
||||
* main.get_node("Camera2D").zoom.x
|
||||
if framed > half_screen.x + 1.0:
|
||||
return _fail_now("aiming framed %.0fpx of beam on %.0fpx of screen" \
|
||||
return _fail_now("framed %.0fpx of aim on %.0fpx of screen" \
|
||||
% [framed, half_screen.x])
|
||||
print("aiming framed the beam's full range")
|
||||
print("aiming framed twice the distance to the target")
|
||||
|
||||
# --- B. targets: two on the line, one off it, one past range ---
|
||||
for offset in [Vector2(200.0, 0.0), Vector2(500.0, 0.0)]:
|
||||
|
|
@ -251,6 +263,31 @@ func _process(delta: float) -> bool:
|
|||
return _fail_now("the aim bent toward an enemy outside the assist cone")
|
||||
print("an enemy outside the cone left the aim where it was pointed")
|
||||
|
||||
# --- F. the drag names a DEPTH, so the aim can reach past a
|
||||
# nearer target instead of always settling on the closest one.
|
||||
var near_enemy: Node = load("res://enemies/Enemy.tscn").instantiate()
|
||||
near_enemy.position = origin + Vector2(700.0, 0.0)
|
||||
main.add_child(near_enemy)
|
||||
near_enemy.speed = 0.0
|
||||
# Further out and off to one side, but still inside the assist
|
||||
# cone: without depth this one is unreachable, because the nearer
|
||||
# enemy wins the cone every time.
|
||||
var far_enemy: Node = load("res://enemies/Enemy.tscn").instantiate()
|
||||
far_enemy.position = origin + Vector2(2000.0, 0.0).rotated(deg_to_rad(10.0))
|
||||
main.add_child(far_enemy)
|
||||
far_enemy.speed = 0.0
|
||||
|
||||
var near_drag := Vector2(700.0 / 2900.0 * DRAG_RADIUS, 0.0)
|
||||
var near_pick: Vector2 = skill._calculate_aim_target(near_drag, origin)
|
||||
if near_pick.distance_to(near_enemy.global_position) > 1.0:
|
||||
return _fail_now("a short drag did not settle on the nearer enemy")
|
||||
var far_drag := Vector2(2000.0 / 2900.0 * DRAG_RADIUS, 0.0) \
|
||||
.rotated(deg_to_rad(10.0))
|
||||
var far_pick: Vector2 = skill._calculate_aim_target(far_drag, origin)
|
||||
if far_pick.distance_to(far_enemy.global_position) > 1.0:
|
||||
return _fail_now("dragging further did not reach past the nearer enemy")
|
||||
print("drag depth selects between a near and a far target in the same cone")
|
||||
|
||||
print("TEST_LASER_VESSEL: PASS")
|
||||
quit(0)
|
||||
return true
|
||||
|
|
|
|||
Loading…
Reference in a new issue