Skip to content

Commit cdddc6a

Browse files
committed
feat(player): re-add shader & and animations after rebase
1 parent f1432e7 commit cdddc6a

File tree

6 files changed

+112
-22
lines changed

6 files changed

+112
-22
lines changed

objects/actors/player/HealthBar.gd

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
extends ProgressBar
2+
3+
var RED_COLOR = "e7001f"
4+
var ORANGE_COLOR = "edae14"
5+
var GREEN_COLOR = "3ac428"
6+
7+
func _process(delta):
8+
if value <= max_value / 10:
9+
modulate = RED_COLOR
10+
elif value <= max_value / 3:
11+
modulate = ORANGE_COLOR
12+
else:
13+
modulate = GREEN_COLOR
14+

objects/actors/player/Player.gd

+2-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ func _on_collecting(element):
6666
if element is Boat:
6767
if hasChest:
6868
element.can_enter = true
69-
$AnimationPlayer.play("fade_away")
70-
71-
if element.can_enter: $AnimationPlayer.play("fade_away")
69+
$AnimationPlayer.play("FadeAway")
7270

71+
if element.can_enter: $AnimationPlayer.play("FadeAway")

objects/actors/player/Player.gdshader

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
shader_type canvas_item;
2+
uniform vec4 blink_color: source_color;
3+
uniform float blink_intensity = 0;
4+
5+
void fragment() {
6+
vec4 color = texture(TEXTURE, UV);
7+
COLOR = mix(color, blink_color, blink_intensity);
8+
COLOR.a = color.a;
9+
}

objects/actors/player/Player.tscn

+87-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
[gd_scene load_steps=73 format=3 uid="uid://bsfyypyhwfbs5"]
1+
[gd_scene load_steps=82 format=3 uid="uid://bsfyypyhwfbs5"]
22

33
[ext_resource type="PackedScene" uid="uid://du0c1yciw8ul6" path="res://objects/actors/Actor.tscn" id="1_wrkhm"]
44
[ext_resource type="Script" path="res://objects/actors/player/Player.gd" id="2_bhjnv"]
5+
[ext_resource type="Shader" path="res://objects/actors/player/DamageFlash.gdshader" id="2_outsh"]
56
[ext_resource type="Resource" uid="uid://r3i80a6v2w0y" path="res://resources/weapons/gun/Gun.tres" id="3_irbyu"]
67
[ext_resource type="Texture2D" uid="uid://dw5vuo3agm77m" path="res://objects/actors/player/template.png" id="3_q5uec"]
78
[ext_resource type="PackedScene" uid="uid://cxlkjx4h6gv5h" path="res://components/collector/Collector.tscn" id="5_q1uwo"]
9+
[ext_resource type="Script" path="res://objects/actors/player/HealthBar.gd" id="7_ot68h"]
810

911
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_p4sxr"]
1012
properties/0/path = NodePath(".:position")
1113
properties/0/spawn = true
1214
properties/0/replication_mode = 1
1315

16+
[sub_resource type="ShaderMaterial" id="ShaderMaterial_6m6gk"]
17+
shader = ExtResource("2_outsh")
18+
shader_parameter/flash_color = Color(0.576083, 0, 0.000370174, 1)
19+
shader_parameter/flash_value = 0.0
20+
1421
[sub_resource type="AtlasTexture" id="AtlasTexture_p8sqi"]
1522
atlas = ExtResource("3_q5uec")
1623
region = Rect2(0, 0, 64, 64)
@@ -508,19 +515,48 @@ radius = 32.0
508515
[sub_resource type="CircleShape2D" id="CircleShape2D_xu8dn"]
509516
radius = 80.0
510517

511-
[sub_resource type="Animation" id="Animation_tc2ku"]
512-
length = 0.001
518+
[sub_resource type="Animation" id="Animation_0v3ge"]
519+
resource_name = "Death"
513520
tracks/0/type = "value"
514521
tracks/0/imported = false
515522
tracks/0/enabled = true
516523
tracks/0/path = NodePath(".:modulate")
517524
tracks/0/interp = 1
518525
tracks/0/loop_wrap = true
519526
tracks/0/keys = {
520-
"times": PackedFloat32Array(0),
521-
"transitions": PackedFloat32Array(1),
527+
"times": PackedFloat32Array(0, 0.75),
528+
"transitions": PackedFloat32Array(1, 1),
522529
"update": 0,
523-
"values": [Color(1, 1, 1, 1)]
530+
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
531+
}
532+
tracks/1/type = "method"
533+
tracks/1/imported = false
534+
tracks/1/enabled = true
535+
tracks/1/path = NodePath(".")
536+
tracks/1/interp = 1
537+
tracks/1/loop_wrap = true
538+
tracks/1/keys = {
539+
"times": PackedFloat32Array(0.75),
540+
"transitions": PackedFloat32Array(1),
541+
"values": [{
542+
"args": [],
543+
"method": &"queue_free"
544+
}]
545+
}
546+
547+
[sub_resource type="Animation" id="Animation_fx0oj"]
548+
resource_name = "Hit"
549+
length = 0.4
550+
tracks/0/type = "bezier"
551+
tracks/0/imported = false
552+
tracks/0/enabled = true
553+
tracks/0/path = NodePath("AnimatedSprite:material:shader_parameter/flash_value")
554+
tracks/0/interp = 1
555+
tracks/0/loop_wrap = true
556+
tracks/0/keys = {
557+
"handle_modes": PackedInt32Array(0, 0, 0),
558+
"points": PackedFloat32Array(0, -0.2, 0, 0.2, 0, 1, -0.2, 0, 0.2, 0, 0, -0.2, 0, 0.2, 0),
559+
"times": PackedFloat32Array(0, 0.2, 0.4)
524560
}
525561

526562
[sub_resource type="Animation" id="Animation_l1t87"]
@@ -552,22 +588,52 @@ tracks/1/keys = {
552588
}]
553589
}
554590

591+
[sub_resource type="Animation" id="Animation_tc2ku"]
592+
length = 0.001
593+
tracks/0/type = "value"
594+
tracks/0/imported = false
595+
tracks/0/enabled = true
596+
tracks/0/path = NodePath(".:modulate")
597+
tracks/0/interp = 1
598+
tracks/0/loop_wrap = true
599+
tracks/0/keys = {
600+
"times": PackedFloat32Array(0),
601+
"transitions": PackedFloat32Array(1),
602+
"update": 0,
603+
"values": [Color(1, 1, 1, 1)]
604+
}
605+
tracks/1/type = "bezier"
606+
tracks/1/imported = false
607+
tracks/1/enabled = true
608+
tracks/1/path = NodePath(".:material:shader_parameter/flash_value")
609+
tracks/1/interp = 1
610+
tracks/1/loop_wrap = true
611+
tracks/1/keys = {
612+
"handle_modes": PackedInt32Array(0),
613+
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0),
614+
"times": PackedFloat32Array(0)
615+
}
616+
555617
[sub_resource type="AnimationLibrary" id="AnimationLibrary_mt86f"]
556618
_data = {
557-
"RESET": SubResource("Animation_tc2ku"),
558-
"fade_away": SubResource("Animation_l1t87")
619+
"Death": SubResource("Animation_0v3ge"),
620+
"FadeAway": SubResource("Animation_l1t87"),
621+
"Hit": SubResource("Animation_fx0oj"),
622+
"RESET": SubResource("Animation_tc2ku")
559623
}
560624

561625
[node name="Player" instance=ExtResource("1_wrkhm")]
562626
collision_mask = 7
563627
script = ExtResource("2_bhjnv")
564628
chestModifierSpeed = 0.7
629+
maxHealth = 100
565630
weapon = ExtResource("3_irbyu")
566631

567632
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="." index="0"]
568633
replication_config = SubResource("SceneReplicationConfig_p4sxr")
569634

570635
[node name="AnimatedSprite" parent="." index="1"]
636+
material = SubResource("ShaderMaterial_6m6gk")
571637
sprite_frames = SubResource("SpriteFrames_67jtf")
572638
animation = &"IdleRight"
573639
autoplay = "IdleDown"
@@ -590,4 +656,17 @@ libraries = {
590656
"": SubResource("AnimationLibrary_mt86f")
591657
}
592658

659+
[node name="HealthBar" type="ProgressBar" parent="." index="6"]
660+
modulate = Color(0.227451, 0.768627, 0.156863, 1)
661+
z_index = 10
662+
offset_left = -68.0
663+
offset_top = -60.0
664+
offset_right = 206.0
665+
offset_bottom = -33.0
666+
scale = Vector2(0.5, 0.5)
667+
mouse_filter = 2
668+
step = 1.0
669+
show_percentage = false
670+
script = ExtResource("7_ot68h")
671+
593672
[connection signal="on_collecting" from="Collector" to="." method="_on_collecting"]

objects/actors/player/health_bar.gd

-11
This file was deleted.

0 commit comments

Comments
 (0)