From ed8c3576c4080c420fe8880de5c4b65671a45f04 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Sat, 4 Jan 2020 19:22:11 +0100 Subject: [PATCH] add blur overlay after win --- game/src/Main.gd | 9 +++++++++ game/src/Main.tscn | 22 +++++++++++++++++++++- game/src/Taquin.gd | 11 +++++------ 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/game/src/Main.gd b/game/src/Main.gd index 3ba56dd..7819e9e 100644 --- a/game/src/Main.gd +++ b/game/src/Main.gd @@ -1,4 +1,13 @@ extends Control +var blur_amount = 3 + +enum State {} + +func _ready(): + $ColorRect.visible = false + func _on_Taquin_solved(): print("Solved!") + $ColorRect.visible = true + $ColorRect.material.set_shader_param("blur_amount", blur_amount) diff --git a/game/src/Main.tscn b/game/src/Main.tscn index b62d395..1ac59bb 100644 --- a/game/src/Main.tscn +++ b/game/src/Main.tscn @@ -1,8 +1,21 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://src/Main.gd" type="Script" id=1] [ext_resource path="res://src/Taquin.tscn" type="PackedScene" id=2] +[sub_resource type="Shader" id=1] +code = "shader_type canvas_item; + +uniform float blur_amount : hint_range(0, 5); + +void fragment() { + COLOR = textureLod(SCREEN_TEXTURE, SCREEN_UV, blur_amount); +}" + +[sub_resource type="ShaderMaterial" id=2] +shader = SubResource( 1 ) +shader_param/blur_amount = null + [node name="Main" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 @@ -19,6 +32,8 @@ margin_bottom = -20.0 [node name="Taquin" parent="HSplitContainer" instance=ExtResource( 2 )] margin_right = 540.0 margin_bottom = 560.0 +rows = 4 +columns = 4 [node name="VSplitContainer" type="VSplitContainer" parent="HSplitContainer"] margin_left = 552.0 @@ -29,4 +44,9 @@ margin_bottom = 560.0 margin_right = 432.0 margin_bottom = 560.0 text = "New game" + +[node name="ColorRect" type="ColorRect" parent="."] +material = SubResource( 2 ) +anchor_right = 1.0 +anchor_bottom = 1.0 [connection signal="solved" from="HSplitContainer/Taquin" to="." method="_on_Taquin_solved"] diff --git a/game/src/Taquin.gd b/game/src/Taquin.gd index 8934172..87d25e6 100644 --- a/game/src/Taquin.gd +++ b/game/src/Taquin.gd @@ -98,19 +98,19 @@ func move_piece(direction) -> bool: var destination: Vector2 = missing_piece match direction: Direction.UP: - print("up") +# print("up") destination.y -= 1 Direction.DOWN: destination.y += 1 - print("down") +# print("down") Direction.LEFT: destination.x -= 1 - print("left") +# print("left") Direction.RIGHT: destination.x += 1 - print("right") +# print("right") - print(destination) +# print(destination) if (destination.x < 0 || destination.x >= columns || destination.y < 0 || destination.y >= rows): print("impossible move") @@ -127,7 +127,6 @@ func move_piece(direction) -> bool: assert(moving_piece_track_index != -1) var new_animation_path: String = str($AnimationPlayer.get_parent().get_path_to(moving_piece), ":position") - print("new animation path: ", new_animation_path) moving_piece_animation.track_set_path(moving_piece_track_index, new_animation_path) current_animation_path = new_animation_path