[gd_scene load_steps=17 format=2]

[ext_resource path="res://assets/sounds/vibing.wav" type="AudioStream" id=1]
[ext_resource path="res://src/UserInterface/TutorialThingy.gd" type="Script" id=2]
[ext_resource path="res://addons/controller_icons/objects/Button.gd" type="Script" id=3]
[ext_resource path="res://assets/ui/fonts/kenny_thick.tres" type="DynamicFont" id=5]
[ext_resource path="res://addons/controller_icons/assets/ps4/cross.png" type="Texture" id=6]
[ext_resource path="res://assets/effects/noise.png" type="Texture" id=8]

[sub_resource type="Shader" id=13]
code = "shader_type canvas_item;

uniform sampler2D noise_tex_normal;
uniform sampler2D noise_tex;
uniform float progress : hint_range(0.0, 1.0);
uniform float scale : hint_range(0.0, 100.0);
uniform float strength = 1.0;

// If your sprite doesn't have enough space and the explosion gets clipped, 
// you can uncomment this and adjust the scale
void vertex() {
 	VERTEX *= scale;

	UV *= scale;
	UV -= (scale - 1.0) / 2.0;
}

void fragment() {
	vec2 direction = texture(noise_tex_normal, UV).xy; // We're using normal map as direction
	direction -= 0.5; // Since our normal map is a texture, it ranges from 0.0 to 1.0...
	direction *= 2.0; // ...so we're going to make it range from -1.0 to 1.0.
	direction = direction * strength * progress;
	
	// UV for exploded texture
	vec2 tex_size = 1.0 / TEXTURE_PIXEL_SIZE; // Real texture size in pixels
	vec2 uv = floor(UV * tex_size) / (tex_size - 1.0); // Pixelate UV to snap pixels
	uv = uv - direction; // Distort UV
	
	// Texture with exploded UV
	vec4 tex = texture(TEXTURE, uv); 
	
	// Dissolve alpha
	float dissolve = texture(noise_tex, UV).x;
	dissolve = step(progress, dissolve);
	tex.a *= dissolve;
	
	// Border (in case the edge of your sprite stretches, otherwise you can remove this block)
	vec2 border_uv = uv * 2.0 - 1.0;
	border_uv = clamp(abs(border_uv), 0.0, 1.0);
	float border = max(border_uv.x, border_uv.y);
	border = ceil(1.0 - border);
	tex.a *= border;
	
	COLOR = tex;
}"

[sub_resource type="ShaderMaterial" id=12]
resource_local_to_scene = true
shader = SubResource( 13 )
shader_param/progress = 0.0
shader_param/scale = 1.0
shader_param/strength = 0.1
shader_param/noise_tex_normal = ExtResource( 8 )
shader_param/noise_tex = ExtResource( 8 )

[sub_resource type="Gradient" id=9]
interpolation_mode = 2
colors = PoolColorArray( 0, 0, 0, 0.784314, 0, 0, 0, 0 )

[sub_resource type="GradientTexture2D" id=8]
gradient = SubResource( 9 )
width = 300
height = 75
fill = 1
fill_from = Vector2( 0.5, 0.5 )
fill_to = Vector2( 0.155994, 0.791965 )

[sub_resource type="Gradient" id=10]
interpolation_mode = 2
colors = PoolColorArray( 1, 1, 1, 1, 0, 0, 0, 0 )

[sub_resource type="GradientTexture2D" id=11]
gradient = SubResource( 10 )
width = 100
height = 100
use_hdr = true
fill = 1
fill_from = Vector2( 0.5, 0.5 )
fill_to = Vector2( 0.155994, 0.791965 )

[sub_resource type="RectangleShape2D" id=3]

[sub_resource type="Animation" id=4]
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath("Button:material:shader_param/progress")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 0.0 ]
}

[sub_resource type="Animation" id=5]
resource_name = "cease_4_exist"
length = 0.618
tracks/0/type = "value"
tracks/0/path = NodePath("Button:material:shader_param/progress")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.3 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ 0.0, 1.0 ]
}
tracks/1/type = "method"
tracks/1/path = NodePath(".")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0.4 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [  ],
"method": "_lesson_learned"
} ]
}

[sub_resource type="RectangleShape2D" id=6]
extents = Vector2( 29, 39 )

[node name="TutorialThingy" type="Node2D"]
physics_interpolation_mode = 1
visible = false
z_index = 10
script = ExtResource( 2 )
action = "jump"
tutorial_text = "Press to Jump:"
press_limit = 1

[node name="Button" type="Sprite" parent="."]
physics_interpolation_mode = 2
material = SubResource( 12 )
scale = Vector2( 0.4, 0.4 )
z_index = 3
texture = ExtResource( 6 )

[node name="ControllerButton" type="Button" parent="Button"]
visible = false
margin_right = 12.0
margin_bottom = 20.0
script = ExtResource( 3 )

[node name="TextureRect" type="TextureRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -150.0
margin_top = -75.0
margin_right = 250.0
margin_bottom = 125.0
texture = SubResource( 8 )

[node name="Label" type="Label" parent="TextureRect"]
physics_interpolation_mode = 2
unique_name_in_owner = true
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -118.0
margin_top = -66.0
margin_right = 15.0
margin_bottom = 33.0
grow_horizontal = 2
grow_vertical = 2
custom_fonts/font = ExtResource( 5 )
text = "This is a test
"
align = 1
uppercase = true

[node name="TextureRect2" type="TextureRect" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -50.0
margin_top = -50.0
margin_right = 50.0
margin_bottom = 50.0
texture = SubResource( 11 )

[node name="Area" type="Area2D" parent="."]
collision_layer = 512
collision_mask = 512

[node name="CollisionShape2D" type="CollisionShape2D" parent="Area"]
shape = SubResource( 3 )

[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/RESET = SubResource( 4 )
anims/cease_4_exist = SubResource( 5 )

[node name="StartTutorialArea" type="Area2D" parent="."]
collision_layer = 0
monitorable = false

[node name="CollisionShape2D" type="CollisionShape2D" parent="StartTutorialArea"]
shape = SubResource( 6 )

[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 1 )
volume_db = -17.477
bus = "UI"

[node name="Sprite" type="Sprite" parent="."]

[connection signal="area_entered" from="Area" to="." method="_on_Area_area_entered"]
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_lesson_learned"]
[connection signal="area_entered" from="StartTutorialArea" to="." method="_on_StartTutorialArea_area_entered"]
