add blur overlay after win
This commit is contained in:
		
							parent
							
								
									df97221788
								
							
						
					
					
						commit
						ed8c3576c4
					
				
					 3 changed files with 35 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
	
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue