-
Notifications
You must be signed in to change notification settings - Fork 1
/
ball.tscn
104 lines (87 loc) · 2.89 KB
/
ball.tscn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
[gd_scene load_steps=9 format=2]
[ext_resource path="res://images/0.png" type="Texture" id=1]
[ext_resource path="res://ball.gd" type="Script" id=2]
[ext_resource path="res://audio/hit.wav" type="AudioStream" id=3]
[ext_resource path="res://audio/fail.wav" type="AudioStream" id=4]
[sub_resource type="PhysicsMaterial" id=1]
friction = 0.5
bounce = 1.0
[sub_resource type="Shader" id=2]
code = "// https://godotshaders.com/shader/2d-motion-blur/
shader_type canvas_item;
render_mode blend_mix;
uniform vec2 dir = vec2(0,0);
uniform int quality = 4;
uniform vec2 deform = vec2(2.0, 2.0);
uniform vec2 offset = vec2(0.0, 0.0);
uniform vec4 modulate : hint_color;
void vertex() {
vec2 blurSize = abs(dir) * 2.0;
VERTEX *= blurSize + 1.0;
UV = (UV - 0.5) * (blurSize + 1.0) + 0.5;
}
float insideUnitSquare(vec2 v) {
vec2 s = step(vec2(0.0), v) - step(vec2(1.0), v);
return s.x * s.y;
}
void fragment() {
float inSquare = insideUnitSquare(UV);
float numSamples = inSquare;
COLOR = texture(TEXTURE, UV) * inSquare;
vec2 stepSize = dir/(float(quality));
vec2 uv;
for(int i = 1; i <= quality; i++) {
uv = UV + stepSize * float(i);
inSquare = insideUnitSquare(uv);
numSamples += inSquare;
COLOR += texture(TEXTURE, uv) * inSquare;
uv = UV - stepSize * float(i);
inSquare = insideUnitSquare(uv);
numSamples += inSquare;
COLOR += texture(TEXTURE, uv) * inSquare;
}
COLOR.rgb /= numSamples;
COLOR.a /= float(quality)*2.0 + 1.0;
}"
[sub_resource type="ShaderMaterial" id=3]
shader = SubResource( 2 )
shader_param/dir = Vector2( 0.03, 0 )
shader_param/quality = 2
shader_param/deform = Vector2( 2, 2 )
shader_param/offset = Vector2( 4, 0 )
shader_param/modulate = Color( 0, 0, 0, 0.72549 )
[sub_resource type="CircleShape2D" id=4]
radius = 26.2487
[node name="ball" type="RigidBody2D"]
collision_layer = 2
collision_mask = 3
physics_material_override = SubResource( 1 )
contacts_reported = 1
contact_monitor = true
linear_damp = -0.5
angular_damp = -0.2
script = ExtResource( 2 )
[node name="sprite" type="Sprite" parent="."]
material = SubResource( 3 )
texture = ExtResource( 1 )
[node name="collision" type="CollisionShape2D" parent="."]
shape = SubResource( 4 )
one_way_collision_margin = 2.0
[node name="sound" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource( 3 )
volume_db = -10.0
max_distance = 600.0
attenuation = 5.0
area_mask = 5
[node name="fail" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource( 4 )
volume_db = -5.0
max_distance = 500.0
attenuation = 5.0
area_mask = 5
[node name="out_of_screen" type="VisibilityNotifier2D" parent="."]
rect = Rect2( -15, -15, 30, 30 )
[node name="drop_fx" type="Tween" parent="."]
[connection signal="body_entered" from="." to="." method="_on_ball_body_entered"]
[connection signal="finished" from="fail" to="." method="_on_fail_finished"]
[connection signal="screen_exited" from="out_of_screen" to="." method="_on_VisibilityNotifier2D_screen_exited"]