taqin/src/Main.gd

34 lines
1 KiB
GDScript3
Raw Normal View History

2019-11-26 13:57:50 +01:00
extends Control
2020-01-12 19:49:25 +01:00
export var blur: int = 3
export var blur_transition_duration: float = 1
2020-02-24 22:56:51 +01:00
2020-01-12 19:49:25 +01:00
var blur_amount: float = 0
var blur_step: float = 0
2020-01-04 19:22:11 +01:00
2020-02-24 22:56:51 +01:00
onready var taquin = $HSplitContainer/Taquin
2020-01-04 19:22:11 +01:00
func _ready():
$ColorRect.visible = false
2020-01-12 19:49:25 +01:00
blur_amount = 0
blur_step = blur / blur_transition_duration
2020-02-24 22:56:51 +01:00
print("Starting state: ", taquin.current_state_name())
taquin.connect("state_changed", self, "_on_Taquin_state_changed")
2020-01-04 19:22:11 +01:00
2020-01-12 19:49:25 +01:00
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)
2020-02-24 22:56:51 +01:00
func _on_Taquin_state_changed(previous, new):
print("Taquin state: ", Taquin.State.keys()[previous], " -> ", Taquin.State.keys()[new])
match new:
Taquin.State.WINNING:
2020-01-07 13:54:06 +01:00
print("Solved!")
# TODO: wait for the animation to finish before game over
2020-01-12 18:51:07 +01:00
#$GameState.transition_to(GameState.State.GAME_OVER)
2020-02-24 22:56:51 +01:00
Taquin.State.GAME_OVER:
2020-01-07 13:54:06 +01:00
$ColorRect.visible = true
$ColorRect.material.set_shader_param("blur_amount", blur_amount)