Refine boss reveal and dash motion

This commit is contained in:
Loïc Wisniewski 2026-09-04 18:40:58 +02:00
commit e5439f7183
4 changed files with 48 additions and 11 deletions

View file

@ -36,6 +36,9 @@ var steer_direction: Vector2 = Vector2.ZERO
# An aimed Propulser burst translates the complete formation as one body.
var dash_direction: Vector2 = Vector2.ZERO
var dash_remaining: float = 0.0
var dash_distance: float = 0.0
var dash_elapsed: float = 0.0
var dash_duration: float = 0.0
const DASH_SPEED: float = 2800.0
@ -230,6 +233,9 @@ func teleport_to(world_pos: Vector2) -> void:
steer_direction = Vector2.ZERO
dash_remaining = 0.0
dash_direction = Vector2.ZERO
dash_distance = 0.0
dash_elapsed = 0.0
dash_duration = 0.0
fleet_target = world_pos
anchor = world_pos
GameState.fleet_position = get_centroid()
@ -259,6 +265,9 @@ func dash(direction: Vector2, distance: float) -> bool:
anchor = get_formation_origin()
dash_direction = direction.normalized()
dash_remaining = distance
dash_distance = distance
dash_elapsed = 0.0
dash_duration = distance / DASH_SPEED
return true
@ -287,7 +296,15 @@ func _process(delta: float) -> void:
func _advance_dash(delta: float) -> void:
var step: float = minf(DASH_SPEED * delta, dash_remaining)
var previous_progress: float = dash_elapsed / dash_duration
dash_elapsed = minf(dash_elapsed + delta, dash_duration)
var progress: float = dash_elapsed / dash_duration
# Cubic ease-out gives the Propulser an immediate punch, then lets the
# formation settle smoothly at the aimed point. Applying the difference
# between eased positions keeps the final distance frame-rate independent.
var previous_distance: float = dash_distance * _dash_curve(previous_progress)
var target_distance: float = dash_distance * _dash_curve(progress)
var step: float = minf(target_distance - previous_distance, dash_remaining)
var displacement: Vector2 = dash_direction * step
dash_remaining -= step
anchor += displacement
@ -309,6 +326,11 @@ func _advance_dash(delta: float) -> void:
_assign_slot_targets()
func _dash_curve(progress: float) -> float:
var remaining: float = 1.0 - clampf(progress, 0.0, 1.0)
return 1.0 - remaining * remaining * remaining
func _effective_cruise_speed() -> float:
return cruise_speed * GameState.fleet_speed_multiplier