fix purge shake: smooth Tween-based summon tremble, visible payoff before flash
parent
6f529e3ffd
commit
d00afe5772
|
|
@ -2,7 +2,7 @@ extends Camera2D
|
||||||
|
|
||||||
var shake_tween: Tween
|
var shake_tween: Tween
|
||||||
|
|
||||||
func shake(duration: float, intensity: float) -> void:
|
func shake(duration: float, intensity: float, constant: bool = false) -> void:
|
||||||
if shake_tween and shake_tween.is_valid():
|
if shake_tween and shake_tween.is_valid():
|
||||||
shake_tween.kill()
|
shake_tween.kill()
|
||||||
|
|
||||||
|
|
@ -10,14 +10,15 @@ func shake(duration: float, intensity: float) -> void:
|
||||||
shake_tween = create_tween()
|
shake_tween = create_tween()
|
||||||
shake_tween.set_pause_mode(Tween.TWEEN_PAUSE_PROCESS)
|
shake_tween.set_pause_mode(Tween.TWEEN_PAUSE_PROCESS)
|
||||||
|
|
||||||
var steps = 20
|
var step_duration := 0.05
|
||||||
var step_duration = duration / steps
|
var steps := maxi(1, int(duration / step_duration))
|
||||||
|
|
||||||
for i in steps:
|
for i in steps:
|
||||||
var t = float(i) / float(steps)
|
var t := float(i) / float(steps)
|
||||||
var decay = 1.0 - t
|
var si := intensity
|
||||||
var si = intensity * decay
|
if not constant:
|
||||||
var target = Vector2(
|
si *= 1.0 - t
|
||||||
|
var target := Vector2(
|
||||||
randf_range(-si, si),
|
randf_range(-si, si),
|
||||||
randf_range(-si, si)
|
randf_range(-si, si)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -2,31 +2,20 @@ extends Node2D
|
||||||
|
|
||||||
const ELITE_DAMAGE_PCT := 0.75
|
const ELITE_DAMAGE_PCT := 0.75
|
||||||
const FLASH_FADE_DURATION := 0.6
|
const FLASH_FADE_DURATION := 0.6
|
||||||
const SUMMON_SHAKE := 2.0
|
|
||||||
|
|
||||||
@onready var summon_circle: AnimatedSprite2D = $SummonCircle/AnimatedSprite2D
|
@onready var summon_circle: AnimatedSprite2D = $SummonCircle/AnimatedSprite2D
|
||||||
@onready var camera = get_node("/root/Game/Camera2D")
|
@onready var camera = get_node("/root/Game/Camera2D")
|
||||||
|
|
||||||
var is_summoning := true
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
summon_circle.sprite_frames = summon_circle.sprite_frames.duplicate()
|
summon_circle.sprite_frames = summon_circle.sprite_frames.duplicate()
|
||||||
summon_circle.sprite_frames.set_animation_loop("default", false)
|
summon_circle.sprite_frames.set_animation_loop("default", false)
|
||||||
summon_circle.animation_finished.connect(_unleash)
|
summon_circle.animation_finished.connect(_unleash)
|
||||||
summon_circle.play("default")
|
summon_circle.play("default")
|
||||||
|
camera.shake(6.0, 1.5, true)
|
||||||
func _process(delta: float) -> void:
|
|
||||||
if is_summoning:
|
|
||||||
camera.offset = Vector2(
|
|
||||||
randf_range(-SUMMON_SHAKE, SUMMON_SHAKE),
|
|
||||||
randf_range(-SUMMON_SHAKE, SUMMON_SHAKE)
|
|
||||||
)
|
|
||||||
|
|
||||||
func _unleash() -> void:
|
func _unleash() -> void:
|
||||||
is_summoning = false
|
camera.shake(0.3, 8.0)
|
||||||
set_process(false)
|
await get_tree().create_timer(0.1).timeout
|
||||||
camera.offset = Vector2.ZERO
|
|
||||||
camera.shake(0.2, 6.0)
|
|
||||||
|
|
||||||
for enemy in get_tree().get_nodes_in_group("enemies"):
|
for enemy in get_tree().get_nodes_in_group("enemies"):
|
||||||
if not is_instance_valid(enemy):
|
if not is_instance_valid(enemy):
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,6 @@ func shoot_purge():
|
||||||
var pg = purge.instantiate()
|
var pg = purge.instantiate()
|
||||||
pg.global_position = global_position
|
pg.global_position = global_position
|
||||||
get_parent().add_child(pg)
|
get_parent().add_child(pg)
|
||||||
camera.shake(0.3, 0.8)
|
|
||||||
|
|
||||||
func take_damage(amount: int, attacker = null) -> void:
|
func take_damage(amount: int, attacker = null) -> void:
|
||||||
if is_invincible:
|
if is_invincible:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue