wipe transition shader! & inside circle shader(:

This commit is contained in:
Harmony Honey 2021-11-04 19:53:55 -04:00
parent d25669708a
commit 4ecd7ac534
7 changed files with 218 additions and 30 deletions

View file

@ -51,11 +51,14 @@ var btn_jump := false
var btnp_jump := false
var btnp_action := false
export var is_debug := false
func _ready():
if Engine.editor_hint: return
readout.resize(4)
label.visible = true
if is_debug:
label.visible = true
for i in get_tree().get_nodes_in_group("game_camera"):
camera = i
@ -246,11 +249,6 @@ func _physics_process(delta):
for i in readout:
label.text += str(i) + "\n"
func _on_PushArea_body_entered(body):
pass
# if is_floor and body.is_in_group("box") and body.is_floor and body.dir % 2 == dir % 2:
# body.push((dir_x == 1) if body.dir == dir else (dir_x == -1))
func _on_BodyArea_area_entered(area):
if area.get_parent().is_in_group("spike"):
print("hit spike")

View file

@ -934,20 +934,8 @@ collision_layer = 0
collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="Areas/HitArea"]
position = Vector2( 1.88773, 0.471939 )
shape = SubResource( 3 )
[node name="ColorRect" type="ColorRect" parent="Areas/HitArea/CollisionShape2D"]
visible = false
margin_left = -35.0
margin_top = -35.0
margin_right = 35.0
margin_bottom = 35.0
color = Color( 1, 0, 0, 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="PushArea" type="Area2D" parent="Areas"]
position = Vector2( 30, 0 )
collision_layer = 0
@ -956,17 +944,6 @@ collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="Areas/PushArea"]
shape = SubResource( 4 )
[node name="ColorRect" type="ColorRect" parent="Areas/PushArea/CollisionShape2D"]
visible = false
margin_left = -2.0
margin_top = -15.0
margin_right = 2.0
margin_bottom = 15.0
color = Color( 0, 1, 0.345098, 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="AudioSlap" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource( 3 )
@ -1030,5 +1007,4 @@ position = Vector2( -106, 30 )
texture = ExtResource( 9 )
[connection signal="area_entered" from="BodyArea" to="." method="_on_BodyArea_area_entered"]
[connection signal="body_entered" from="Areas/PushArea" to="." method="_on_PushArea_body_entered"]
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"]

11
src/fx/Wipe.gd Normal file
View file

@ -0,0 +1,11 @@
extends Node2D
var shader_scale = 100.0
func _ready():
get_tree().get_root().connect("size_changed", self, "size_changed")
func size_changed():
$Sprite.material.set_shader_param("scale", (get_viewport().size.x/ 1280) * shader_scale)
print(get_viewport_rect())

58
src/fx/Wipe.tscn Normal file
View file

@ -0,0 +1,58 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://src/shader/wipe.gdshader" type="Shader" id=1]
[ext_resource path="res://media/image/rect.png" type="Texture" id=2]
[ext_resource path="res://src/fx/Wipe.gd" type="Script" id=3]
[sub_resource type="ShaderMaterial" id=2]
shader = ExtResource( 1 )
shader_param/inside = Color( 1, 1, 1, 1 )
shader_param/line = Color( 0, 0, 0, 1 )
shader_param/outside = Color( 0, 0, 0, 0 )
shader_param/scale = 90.0
shader_param/offset = Vector2( 0.6, 0.5 )
shader_param/radius = 0.0
shader_param/width = 0.2
[sub_resource type="Animation" id=3]
resource_name = "in"
tracks/0/type = "bezier"
tracks/0/path = NodePath("Sprite:material:shader_param/radius")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"points": PoolRealArray( 0, -0.3, 0, 0.4, 0, 0.9, -0.3, 0, 0.4, 0 ),
"times": PoolRealArray( 0, 1 )
}
[sub_resource type="Animation" id=4]
resource_name = "out"
tracks/0/type = "bezier"
tracks/0/path = NodePath("Sprite:material:shader_param/radius")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"points": PoolRealArray( 0.9, -0.3, 0, 0.4, 0, 0, -0.3, 0, 0.4, 0 ),
"times": PoolRealArray( 0, 1 )
}
[node name="Wipe" type="Node2D"]
script = ExtResource( 3 )
[node name="Sprite" type="Sprite" parent="."]
material = SubResource( 2 )
texture = ExtResource( 2 )
centered = false
region_enabled = true
region_rect = Rect2( 0, 0, 1280, 720 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "in"
anims/in = SubResource( 3 )
anims/out = SubResource( 4 )
next/in = "out"
next/out = "in"

95
src/menu/LevelSelect.tscn Normal file
View file

@ -0,0 +1,95 @@
[gd_scene load_steps=6 format=2]
[ext_resource path="res://src/map/_test/0.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/shader/inside_circle.gdshader" type="Shader" id=2]
[ext_resource path="res://src/map/world1/1.tscn" type="PackedScene" id=3]
[sub_resource type="Animation" id=3]
resource_name = "idle"
length = 3.0
loop = true
tracks/0/type = "bezier"
tracks/0/path = NodePath("ViewportContainer:material:shader_param/radius")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"points": PoolRealArray( 0.5, -0.6, 0, 0.6, 0, 0.4, -0.6, 0, 0.6, 0, 0.5, -0.6, 0, 0.6, 0 ),
"times": PoolRealArray( 0, 1.5, 3 )
}
[sub_resource type="ShaderMaterial" id=2]
shader = ExtResource( 2 )
shader_param/radius = 0.429258
shader_param/width = 0.033
[node name="LevelSelect" type="Node2D"]
[node name="ColorRect" type="ColorRect" parent="."]
margin_left = -700.0
margin_top = -400.0
margin_right = 700.0
margin_bottom = 400.0
color = Color( 1, 0.92, 0.92, 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Camera2D" type="Camera2D" parent="."]
current = true
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "idle"
anims/idle = SubResource( 3 )
[node name="ViewportContainer" type="ViewportContainer" parent="."]
material = SubResource( 2 )
margin_left = -550.0
margin_top = -250.0
margin_right = -50.0
margin_bottom = 250.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Viewport" type="Viewport" parent="ViewportContainer"]
size = Vector2( 500, 500 )
handle_input_locally = false
render_target_update_mode = 3
[node name="Node2D" parent="ViewportContainer/Viewport" instance=ExtResource( 1 )]
[node name="ViewportContainer3" type="ViewportContainer" parent="."]
material = SubResource( 2 )
margin_left = 50.0
margin_top = -250.0
margin_right = 550.0
margin_bottom = 250.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Viewport" type="Viewport" parent="ViewportContainer3"]
size = Vector2( 500, 500 )
handle_input_locally = false
render_target_update_mode = 3
[node name="Node2D" parent="ViewportContainer3/Viewport" instance=ExtResource( 1 )]
[node name="ViewportContainer2" type="ViewportContainer" parent="."]
material = SubResource( 2 )
margin_left = -250.0
margin_top = -250.0
margin_right = 250.0
margin_bottom = 250.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Viewport" type="Viewport" parent="ViewportContainer2"]
size = Vector2( 500, 500 )
handle_input_locally = false
render_target_update_mode = 3
[node name="Node2D" parent="ViewportContainer2/Viewport" instance=ExtResource( 3 )]

View file

@ -0,0 +1,20 @@
shader_type canvas_item;
uniform float radius : hint_range(0.0, 0.5) = 0.5;
uniform float width : hint_range(0.0, 0.2) = 0.05;
void fragment(){
float dist = distance(vec2(0.5, 0.5), UV);
if (dist < radius - width){
COLOR = texture(TEXTURE, UV);
}
else if (dist < radius) {
COLOR = vec4(0.0, 0.0, 0.0, 1.0);
}
else {
COLOR = vec4(0.0, 0.0, 0.0, 0.0);
}
}

30
src/shader/wipe.gdshader Normal file
View file

@ -0,0 +1,30 @@
shader_type canvas_item;
uniform vec4 inside : hint_color = vec4(1.0, 1.0, 1.0, 1.0);
uniform vec4 line : hint_color = vec4(0.0, 0.0, 0.0, 1.0);
uniform vec4 outside : hint_color = vec4(1.0, 1.0, 1.0, 1.0);
uniform float scale = 100.0;
uniform vec2 offset = vec2(0.5);
uniform float radius : hint_range(0.0, 1.0) = 0.5;
uniform float width : hint_range(0.0, 0.2) = 0.05;
void fragment(){
float dist = distance(vec2(0.5), mod(UV, 1.0));
dist = distance(vec2(0.5), mod((FRAGCOORD.xy / scale) - offset , 1.0));
if (dist < radius - width){
COLOR = inside;
}
else if (dist < radius) {
COLOR = line;
}
else {
COLOR = outside;
}
//COLOR = texture(TEXTURE, UV);
}