Use fire stick magnitude for aim distance
This commit is contained in:
parent
eb1615ab6b
commit
7892a162f3
2 changed files with 27 additions and 10 deletions
|
|
@ -19,8 +19,8 @@ extends SceneTree
|
|||
# heading - and each one's line actually arrives at the point
|
||||
# B. the mouse hands over a place: the cursor's world position, distance
|
||||
# included, rather than a bearing from the fleet's centre
|
||||
# C. a pushed stick still works, resolving to the point at the guns' reach
|
||||
# along it - the touch player loses nothing
|
||||
# C. stick displacement controls convergence distance: a partial push aims
|
||||
# nearby and a full push reaches the guns' maximum range
|
||||
# D. the assist (#89) still bends a shot onto an enemy, now per hull and
|
||||
# around each hull's own heading to the point
|
||||
# E. releasing stops every gun in the fleet
|
||||
|
|
@ -173,6 +173,22 @@ func _process(delta: float) -> bool:
|
|||
return _fail("a pushed stick aimed a hull somewhere other than the point it names")
|
||||
print("a pushed stick names the point at the guns' reach (%.0f) along it" % reach)
|
||||
|
||||
# A half push must keep its magnitude. TouchJoystick already reports
|
||||
# displacement in the 0..1 range; normalizing it here used to turn
|
||||
# every nonzero push into a maximum-range aim.
|
||||
var partial := Vector2(0.0, -0.45)
|
||||
var partial_point: Vector2 = controller.stick_point(partial)
|
||||
var partial_wanted: Vector2 = fleet.get_centroid() + partial * reach
|
||||
if partial_point.distance_to(partial_wanted) > 1.0:
|
||||
return _fail("a 45%% stick push resolved to %s, expected nearby point %s" \
|
||||
% [partial_point, partial_wanted])
|
||||
controller.aim(partial)
|
||||
for ship in [left_ship, right_ship]:
|
||||
if _weapon(ship).fire_target.distance_to(partial_wanted) > 1.0:
|
||||
return _fail("a partial stick push did not aim the fleet at its nearer point")
|
||||
print("a 45%% stick push aims at 45%% range (%.0f), not maximum range" \
|
||||
% fleet.get_centroid().distance_to(partial_point))
|
||||
|
||||
# --- F. reach is the gun's, not the aim's -------------------
|
||||
var far_point: Vector2 = fleet.get_centroid() + Vector2(0.0, -reach * 3.0)
|
||||
controller.aim_at(far_point)
|
||||
|
|
|
|||
Loading…
Reference in a new issue