-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
player speed upgrade and vignette effect
`VelocityComponent` is used in Player scene for speed acceleration and upgrade updates Vignette is implemented with Shader from: `https://godotshaders.com/shader/color-vignetting`
- Loading branch information
1 parent
d61d918
commit a4416f4
Showing
9 changed files
with
182 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[gd_resource type="Resource" script_class="AbilityUpgrade" load_steps=2 format=3 uid="uid://1yg3d35wh0md"] | ||
|
||
[ext_resource type="Script" path="res://resources/upgrades/ability_upgrade.gd" id="1_qlos1"] | ||
|
||
[resource] | ||
script = ExtResource("1_qlos1") | ||
id = "player_speed" | ||
max_quantity = 2 | ||
name = "Move Speed" | ||
description = "Increases player movement speed by 10%." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
extends CanvasLayer | ||
|
||
|
||
func _ready(): | ||
GameEvents.player_damaged.connect(on_player_damaged) | ||
|
||
|
||
func on_player_damaged(): | ||
$AnimationPlayer.play("hit") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
shader_type canvas_item; | ||
|
||
uniform float vignette_intensity = 0.4; | ||
uniform float vignette_opacity : hint_range(0.0, 1.0) = 0.5; | ||
uniform vec4 vignette_rgb : source_color = vec4(0.0, 0.0, 0.0, 1.0); | ||
|
||
float vignette(vec2 uv){ | ||
uv *= 1.0 - uv.xy; | ||
float vignette = uv.x * uv.y * 15.0; | ||
return pow(vignette, vignette_intensity * vignette_opacity); | ||
} | ||
|
||
void fragment(){ | ||
vec4 text = texture(TEXTURE, UV); | ||
|
||
text.rgba *= (vignette_rgb.rgba); | ||
text.rgba *= (1.0 - vignette(UV)); | ||
|
||
COLOR = vec4(text.rgb,text.a); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
[gd_scene load_steps=7 format=3 uid="uid://dtryyvn2r6lfw"] | ||
|
||
[ext_resource type="Script" path="res://scenes/ui/vignette.gd" id="1_18okb"] | ||
[ext_resource type="Shader" path="res://scenes/ui/vignette.gdshader" id="1_hhs4t"] | ||
|
||
[sub_resource type="Animation" id="Animation_ahjpg"] | ||
resource_name = "hit" | ||
length = 0.4 | ||
step = 0.05 | ||
tracks/0/type = "value" | ||
tracks/0/imported = false | ||
tracks/0/enabled = true | ||
tracks/0/path = NodePath("ColorRect:material:shader_parameter/vignette_intensity") | ||
tracks/0/interp = 1 | ||
tracks/0/loop_wrap = true | ||
tracks/0/keys = { | ||
"times": PackedFloat32Array(0, 0.05, 0.4), | ||
"transitions": PackedFloat32Array(1, 2.73208, 1), | ||
"update": 0, | ||
"values": [0.7, 3.0, 0.7] | ||
} | ||
tracks/1/type = "value" | ||
tracks/1/imported = false | ||
tracks/1/enabled = true | ||
tracks/1/path = NodePath("ColorRect:material:shader_parameter/vignette_rgb") | ||
tracks/1/interp = 1 | ||
tracks/1/loop_wrap = true | ||
tracks/1/keys = { | ||
"times": PackedFloat32Array(0.05, 0.4), | ||
"transitions": PackedFloat32Array(2.63902, 1), | ||
"update": 0, | ||
"values": [Color(0.909804, 0.270588, 0.215686, 1), Color(0.247059, 0.14902, 0.192157, 1)] | ||
} | ||
tracks/2/type = "value" | ||
tracks/2/imported = false | ||
tracks/2/enabled = true | ||
tracks/2/path = NodePath("ColorRect:material:shader_parameter/vignette_opacity") | ||
tracks/2/interp = 1 | ||
tracks/2/loop_wrap = true | ||
tracks/2/keys = { | ||
"times": PackedFloat32Array(0, 0.05, 0.4), | ||
"transitions": PackedFloat32Array(1, 1, 1), | ||
"update": 0, | ||
"values": [0.125, 0.325, 0.125] | ||
} | ||
|
||
[sub_resource type="Animation" id="Animation_7hlu1"] | ||
length = 0.001 | ||
tracks/0/type = "value" | ||
tracks/0/imported = false | ||
tracks/0/enabled = true | ||
tracks/0/path = NodePath("ColorRect:material:shader_parameter/vignette_rgb") | ||
tracks/0/interp = 1 | ||
tracks/0/loop_wrap = true | ||
tracks/0/keys = { | ||
"times": PackedFloat32Array(0), | ||
"transitions": PackedFloat32Array(1), | ||
"update": 0, | ||
"values": [Color(0.247059, 0.14902, 0.192157, 1)] | ||
} | ||
tracks/1/type = "value" | ||
tracks/1/imported = false | ||
tracks/1/enabled = true | ||
tracks/1/path = NodePath("ColorRect:material:shader_parameter/vignette_intensity") | ||
tracks/1/interp = 1 | ||
tracks/1/loop_wrap = true | ||
tracks/1/keys = { | ||
"times": PackedFloat32Array(0), | ||
"transitions": PackedFloat32Array(1), | ||
"update": 0, | ||
"values": [0.7] | ||
} | ||
tracks/2/type = "value" | ||
tracks/2/imported = false | ||
tracks/2/enabled = true | ||
tracks/2/path = NodePath("ColorRect:material:shader_parameter/vignette_opacity") | ||
tracks/2/interp = 1 | ||
tracks/2/loop_wrap = true | ||
tracks/2/keys = { | ||
"times": PackedFloat32Array(0), | ||
"transitions": PackedFloat32Array(1), | ||
"update": 0, | ||
"values": [0.125] | ||
} | ||
|
||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_o6tj5"] | ||
_data = { | ||
"RESET": SubResource("Animation_7hlu1"), | ||
"hit": SubResource("Animation_ahjpg") | ||
} | ||
|
||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gihtf"] | ||
shader = ExtResource("1_hhs4t") | ||
shader_parameter/vignette_intensity = 0.7 | ||
shader_parameter/vignette_opacity = 0.125 | ||
shader_parameter/vignette_rgb = Color(0.247059, 0.14902, 0.192157, 1) | ||
|
||
[node name="Vignette" type="CanvasLayer"] | ||
script = ExtResource("1_18okb") | ||
|
||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."] | ||
libraries = { | ||
"": SubResource("AnimationLibrary_o6tj5") | ||
} | ||
|
||
[node name="ColorRect" type="ColorRect" parent="."] | ||
material = SubResource("ShaderMaterial_gihtf") | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
mouse_filter = 2 |