From cf24e8678165c560a3e01840797655b8fd358008 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Sun, 12 Jan 2020 19:49:25 +0100 Subject: [PATCH] slowly transition to game over --- game/src/Main.gd | 13 ++++++++++++- game/src/Main.tscn | 2 +- game/src/Taquin.gd | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/game/src/Main.gd b/game/src/Main.gd index 92ce14b..84b282c 100644 --- a/game/src/Main.gd +++ b/game/src/Main.gd @@ -1,11 +1,22 @@ extends Control -var blur_amount = 3 +export var blur: int = 3 +export var blur_transition_duration: float = 1 +var blur_amount: float = 0 +var blur_step: float = 0 func _ready(): $ColorRect.visible = false + blur_amount = 0 + blur_step = blur / blur_transition_duration print("Starting state: ", $GameState.current_state_name()) +func _process(delta): + if blur_amount < blur: + blur_amount += delta * blur_step + print("blur: ", blur_amount) + $ColorRect.material.set_shader_param("blur_amount", blur_amount) + func _on_GameState_state_changed(previous, current): print("GameState: ", $GameState.State.keys()[previous], " -> ", $GameState.State.keys()[current]) match current: diff --git a/game/src/Main.tscn b/game/src/Main.tscn index 40daf94..80ebc2c 100644 --- a/game/src/Main.tscn +++ b/game/src/Main.tscn @@ -53,5 +53,5 @@ anchor_bottom = 1.0 [node name="GameState" type="Node" parent="."] script = ExtResource( 3 ) -[connection signal="state_changed" from="GameState" to="." method="_on_GameState_state_changed"] [connection signal="state_changed" from="GameState" to="HSplitContainer/Taquin" method="_on_GameState_state_changed"] +[connection signal="state_changed" from="GameState" to="." method="_on_GameState_state_changed"] diff --git a/game/src/Taquin.gd b/game/src/Taquin.gd index 5d50426..caf4103 100644 --- a/game/src/Taquin.gd +++ b/game/src/Taquin.gd @@ -185,6 +185,7 @@ func _on_GameState_state_changed(previous, current): $Particles2D.emitting = true $Timer.start(-1) GameState.State.GAME_OVER: + $Particles2D.emitting = false $Timer.stop() func _on_Timer_timeout():