diff --git a/Effects/tube_steer.gd b/Effects/tube_steer.gd index 43e7e19..02d9c52 100755 --- a/Effects/tube_steer.gd +++ b/Effects/tube_steer.gd @@ -64,6 +64,10 @@ const INDICATOR_PULSE_SPEED = 2.5 # Radians per second (a pulse every 2.5s or so const INDICATOR_MIN_OPACITY = 0.4 const INDICATOR_MAX_OPACITY = 0.6 const INDICATOR_MAX_LIGHTEN = 0.2 +# The circle is hidden while the goo is going in or pouring out. It grows in +# once the goo is all in, and shrinks away quickly when it starts to pour out. +const INDICATOR_APPEAR_TIME = 0.25 # Seconds. +const INDICATOR_DISAPPEAR_TIME = 0.1 # Seconds. const DIRECTIONS: Array[Vector2i] = [Vector2i.UP, Vector2i.RIGHT, Vector2i.DOWN, Vector2i.LEFT] const NEIGHBORS_4: Array[Vector2i] = [Vector2i.UP, Vector2i.RIGHT, Vector2i.DOWN, Vector2i.LEFT] @@ -105,6 +109,7 @@ var _isPouring := false # Once we're leaving: the leader carries on out by itsel var _stickOut := 0 var _moveOwed := 0.0 # Time we're owed moving but haven't used, in seconds. var _time := 0.0 +var _indicatorShown := 0.0 # How far the circle has grown in, from 0 (hidden) to 1. # The pixels: row r holds pixels r * _pixelsPerRow up to the next row's, going # across its _laneCount lanes and round again. @@ -214,6 +219,10 @@ func steer(input: Vector2, delta: float) -> void: func _process(delta: float) -> void: _time += delta + if _isTakingIn or _isPouring: + _indicatorShown = maxf(_indicatorShown - delta / INDICATOR_DISAPPEAR_TIME, 0.0) + else: + _indicatorShown = minf(_indicatorShown + delta / INDICATOR_APPEAR_TIME, 1.0) queue_redraw() @@ -704,21 +713,24 @@ func _draw() -> void: for at: Vector2i in movingPixels: draw_rect(Rect2(Vector2(at), Vector2.ONE), movingPixels[at]) - if leaderPixelCount > 0: + if leaderPixelCount > 0 and _indicatorShown > 0.0: _draw_indicator(leaderCentre / leaderPixelCount) # The circle marking the leader, pulsing its opacity and brightness slowly. +# While it's appearing or disappearing, it's smaller and fainter. func _draw_indicator(centre: Vector2) -> void: var wave := 0.5 + 0.5 * sin(_time * INDICATOR_PULSE_SPEED) - var opacity := lerpf(INDICATOR_MIN_OPACITY, INDICATOR_MAX_OPACITY, wave) + var shown := ease(_indicatorShown, 0.5) # Quick to start growing, settling gently. + var opacity := lerpf(INDICATOR_MIN_OPACITY, INDICATOR_MAX_OPACITY, wave) * shown var lighten := INDICATOR_MAX_LIGHTEN * wave var fill := indicatorColor.lightened(lighten) fill.a *= opacity var border := indicatorBorderColor.lightened(lighten) border.a *= opacity - draw_circle(centre, indicatorRadius, fill) - draw_circle(centre, indicatorRadius, border, false, 1.0) + var radius := indicatorRadius * shown + draw_circle(centre, radius, fill) + draw_circle(centre, radius, border, false, 1.0) # Which way a row's lanes spread at `vertex`: across the tube there.