Fixed Signals, effects, and collisions.

This commit is contained in:
Alan Youngblood 2025-01-18 12:02:23 -05:00
parent 41db52db5c
commit 3db440b7a9
10 changed files with 231 additions and 149 deletions

View File

@ -1,7 +1,6 @@
extends AnimatedSprite2D
func _ready():
connect("animation_finished", Callable(self, "_on_animation_finished"))
frame = 0
play("Animate")

View File

@ -1,63 +1,95 @@
[gd_scene load_steps=15 format=2]
[gd_scene load_steps=15 format=3 uid="uid://bv2jjgk6veq4l"]
[ext_resource path="res://Effects/Effect.gd" type="Script" id=1]
[ext_resource path="res://Effects/EnemyDeathEffect.png" type="Texture2D" id=2]
[ext_resource path="res://Music and Sounds/EnemyDie.wav" type="AudioStream" id=3]
[ext_resource type="Script" path="res://Effects/Effect.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://bmfqf7no8uc14" path="res://Effects/EnemyDeathEffect.png" id="2"]
[ext_resource type="AudioStream" uid="uid://ceo7s8pddaqww" path="res://Music and Sounds/EnemyDie.wav" id="3"]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 2 )
region = Rect2( 0, 0, 32, 32 )
[sub_resource type="AtlasTexture" id="1"]
atlas = ExtResource("2")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 2 )
region = Rect2( 32, 0, 32, 32 )
[sub_resource type="AtlasTexture" id="2"]
atlas = ExtResource("2")
region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 2 )
region = Rect2( 64, 0, 32, 32 )
[sub_resource type="AtlasTexture" id="3"]
atlas = ExtResource("2")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 2 )
region = Rect2( 96, 0, 32, 32 )
[sub_resource type="AtlasTexture" id="4"]
atlas = ExtResource("2")
region = Rect2(96, 0, 32, 32)
[sub_resource type="AtlasTexture" id=5]
atlas = ExtResource( 2 )
region = Rect2( 128, 0, 32, 32 )
[sub_resource type="AtlasTexture" id="5"]
atlas = ExtResource("2")
region = Rect2(128, 0, 32, 32)
[sub_resource type="AtlasTexture" id=6]
atlas = ExtResource( 2 )
region = Rect2( 160, 0, 32, 32 )
[sub_resource type="AtlasTexture" id="6"]
atlas = ExtResource("2")
region = Rect2(160, 0, 32, 32)
[sub_resource type="AtlasTexture" id=7]
atlas = ExtResource( 2 )
region = Rect2( 192, 0, 32, 32 )
[sub_resource type="AtlasTexture" id="7"]
atlas = ExtResource("2")
region = Rect2(192, 0, 32, 32)
[sub_resource type="AtlasTexture" id=8]
atlas = ExtResource( 2 )
region = Rect2( 224, 0, 32, 32 )
[sub_resource type="AtlasTexture" id="8"]
atlas = ExtResource("2")
region = Rect2(224, 0, 32, 32)
[sub_resource type="AtlasTexture" id=9]
atlas = ExtResource( 2 )
region = Rect2( 256, 0, 32, 32 )
[sub_resource type="AtlasTexture" id="9"]
atlas = ExtResource("2")
region = Rect2(256, 0, 32, 32)
[sub_resource type="AtlasTexture" id=10]
atlas = ExtResource( 2 )
region = Rect2( 288, 0, 32, 32 )
[sub_resource type="AtlasTexture" id="10"]
atlas = ExtResource("2")
region = Rect2(288, 0, 32, 32)
[sub_resource type="SpriteFrames" id=11]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ) ],
"loop": true,
"name": "Animate",
[sub_resource type="SpriteFrames" id="11"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("1")
}, {
"duration": 1.0,
"texture": SubResource("2")
}, {
"duration": 1.0,
"texture": SubResource("3")
}, {
"duration": 1.0,
"texture": SubResource("4")
}, {
"duration": 1.0,
"texture": SubResource("5")
}, {
"duration": 1.0,
"texture": SubResource("6")
}, {
"duration": 1.0,
"texture": SubResource("7")
}, {
"duration": 1.0,
"texture": SubResource("8")
}, {
"duration": 1.0,
"texture": SubResource("9")
}, {
"duration": 1.0,
"texture": SubResource("10")
}],
"loop": false,
"name": &"Animate",
"speed": 15.0
} ]
}]
[node name="EnemyDeathEffect" type="AnimatedSprite2D"]
frames = SubResource( 11 )
animation = "Animate"
offset = Vector2( 0, -8 )
script = ExtResource( 1 )
sprite_frames = SubResource("11")
animation = &"Animate"
offset = Vector2(0, -8)
script = ExtResource("1")
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 3 )
stream = ExtResource("3")
autoplay = true
[connection signal="animation_finished" from="." to="." method="_on_animation_finished"]

View File

@ -1,39 +1,58 @@
[gd_scene load_steps=9 format=2]
[gd_scene load_steps=9 format=3 uid="uid://mhvl6s2ugm6y"]
[ext_resource path="res://Effects/GrassEffect.png" type="Texture2D" id=1]
[ext_resource path="res://Effects/Effect.gd" type="Script" id=2]
[ext_resource type="Texture2D" uid="uid://b7rtfcem8vbxx" path="res://Effects/GrassEffect.png" id="1"]
[ext_resource type="Script" path="res://Effects/Effect.gd" id="2"]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 0, 0, 32, 32 )
[sub_resource type="AtlasTexture" id="1"]
atlas = ExtResource("1")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 32, 0, 32, 32 )
[sub_resource type="AtlasTexture" id="2"]
atlas = ExtResource("1")
region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 1 )
region = Rect2( 64, 0, 32, 32 )
[sub_resource type="AtlasTexture" id="3"]
atlas = ExtResource("1")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 1 )
region = Rect2( 96, 0, 32, 32 )
[sub_resource type="AtlasTexture" id="4"]
atlas = ExtResource("1")
region = Rect2(96, 0, 32, 32)
[sub_resource type="AtlasTexture" id=5]
atlas = ExtResource( 1 )
region = Rect2( 128, 0, 32, 32 )
[sub_resource type="AtlasTexture" id="5"]
atlas = ExtResource("1")
region = Rect2(128, 0, 32, 32)
[sub_resource type="SpriteFrames" id=6]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ) ],
"loop": true,
"name": "Animate",
[sub_resource type="SpriteFrames" id="6"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("1")
}, {
"duration": 1.0,
"texture": SubResource("2")
}, {
"duration": 1.0,
"texture": SubResource("3")
}, {
"duration": 1.0,
"texture": SubResource("4")
}, {
"duration": 1.0,
"texture": SubResource("5")
}],
"loop": false,
"name": &"Animate",
"speed": 15.0
} ]
}]
[node name="GrassEffect" type="AnimatedSprite2D"]
frames = SubResource( 6 )
animation = "Animate"
sprite_frames = SubResource("6")
animation = &"Animate"
frame = 1
frame_progress = 0.606911
centered = false
offset = Vector2( -8, -8 )
script = ExtResource( 2 )
offset = Vector2(-8, -8)
script = ExtResource("2")
[connection signal="animation_finished" from="." to="." method="_on_animation_finished"]

View File

@ -1,31 +1,39 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=7 format=3 uid="uid://bojbqk7e5s22v"]
[ext_resource path="res://Effects/Effect.gd" type="Script" id=1]
[ext_resource path="res://Effects/HitEffect.png" type="Texture2D" id=2]
[ext_resource path="res://Music and Sounds/Hit.wav" type="AudioStream" id=3]
[ext_resource type="Script" path="res://Effects/Effect.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://bah6dkm2id" path="res://Effects/HitEffect.png" id="2"]
[ext_resource type="AudioStream" uid="uid://ce47h2cdpm1l6" path="res://Music and Sounds/Hit.wav" id="3"]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 2 )
region = Rect2( 0, 0, 24, 24 )
[sub_resource type="AtlasTexture" id="1"]
atlas = ExtResource("2")
region = Rect2(0, 0, 24, 24)
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 2 )
region = Rect2( 24, 0, 24, 24 )
[sub_resource type="AtlasTexture" id="2"]
atlas = ExtResource("2")
region = Rect2(24, 0, 24, 24)
[sub_resource type="SpriteFrames" id=3]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ) ],
"loop": true,
"name": "Animate",
[sub_resource type="SpriteFrames" id="3"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("1")
}, {
"duration": 1.0,
"texture": SubResource("2")
}],
"loop": false,
"name": &"Animate",
"speed": 10.0
} ]
}]
[node name="HitEffect" type="AnimatedSprite2D"]
frames = SubResource( 3 )
animation = "Animate"
offset = Vector2( 0, -8 )
script = ExtResource( 1 )
sprite_frames = SubResource("3")
animation = &"Animate"
offset = Vector2(0, -8)
script = ExtResource("1")
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 3 )
stream = ExtResource("3")
autoplay = true
[connection signal="animation_finished" from="." to="." method="_on_animation_finished"]

View File

@ -156,6 +156,7 @@ shape = SubResource("7")
[node name="Hurtbox" parent="." instance=ExtResource("3")]
collision_layer = 8
collision_mask = 2
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
position = Vector2(0, -14)
@ -173,13 +174,14 @@ shape = SubResource("9")
[node name="Hitbox" parent="." instance=ExtResource("7")]
visible = false
collision_mask = 4
collision_layer = 16
[node name="CollisionShape2D" parent="Hitbox" index="0"]
position = Vector2(0, -15)
shape = SubResource("10")
[node name="SoftCollision" parent="." instance=ExtResource("8")]
collision_mask = 3
[node name="CollisionShape2D" parent="SoftCollision" index="0"]
shape = SubResource("11")

View File

@ -99,18 +99,15 @@ func attack_aninimation_finished():
#func _process(delta):
# pass
func _on_Hurtbox_invincibility_started():
blinkAnimationPlayer.play("Start")
func _on_Hurtbox_area_entered(_area):
func _on_Hurtbox_invincibility_ended():
blinkAnimationPlayer.play("Stop")
func _on_hurtbox_area_entered(area: Area2D) -> void:
stats.health -= 1
hurtBox.start_invincibility(0.6)
hurtBox.create_hit_effect()
var playerHurtSounds = PlayerHurtSound.instantiate()
get_tree().current_scene.add_child(playerHurtSounds)
func _on_Hurtbox_invincibility_started():
blinkAnimationPlayer.play("Start")
func _on_Hurtbox_invincibility_ended():
blinkAnimationPlayer.play("Stop")

View File

@ -812,15 +812,15 @@ states/Roll/position = Vector2(325, -25.5)
states/Run/node = SubResource("24")
states/Run/position = Vector2(509.5, 96.5)
transitions = ["Run", "Idle", SubResource("25"), "Idle", "Run", SubResource("26"), "Idle", "Attack", SubResource("36"), "Attack", "Idle", SubResource("37"), "Attack", "Run", SubResource("38"), "Run", "Attack", SubResource("39"), "Roll", "Idle", SubResource("50"), "Idle", "Roll", SubResource("51")]
graph_offset = Vector2(-10, -78)
graph_offset = Vector2(-304, -64)
[sub_resource type="CapsuleShape2D" id="40"]
radius = 6.0
height = 12.0
radius = 8.0
height = 28.0
[sub_resource type="CapsuleShape2D" id="52"]
radius = 5.0
height = 14.0
radius = 7.0
height = 18.0
[sub_resource type="Animation" id="56"]
length = 0.001
@ -913,15 +913,17 @@ position = Vector2(0, -4)
[node name="SwordHitbox" parent="HitboxPivot" instance=ExtResource("3")]
position = Vector2(15, 0)
collision_mask = 8
collision_layer = 2
script = ExtResource("4")
[node name="CollisionShape2D" parent="HitboxPivot/SwordHitbox" index="0"]
shape = SubResource("40")
disabled = true
debug_color = Color(0.993005, 0, 0.24396, 0.42)
[node name="Hurtbox" parent="." instance=ExtResource("5")]
collision_layer = 4
collision_mask = 16
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
position = Vector2(0, -4)
@ -934,7 +936,7 @@ libraries = {
"": SubResource("AnimationLibrary_wmxcy")
}
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[connection signal="area_entered" from="Hurtbox" to="." method="_on_hurtbox_area_entered"]
[connection signal="invincibility_ended" from="Hurtbox" to="." method="_on_Hurtbox_invincibility_ended"]
[connection signal="invincibility_started" from="Hurtbox" to="." method="_on_Hurtbox_invincibility_started"]

View File

@ -1,25 +1,29 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=4 format=3 uid="uid://b1uyh26kmvwq6"]
[ext_resource path="res://UI/HealthUI.gd" type="Script" id=1]
[ext_resource path="res://UI/HeartUIEmpty.png" type="Texture2D" id=2]
[ext_resource path="res://UI/HeartUIFull.png" type="Texture2D" id=3]
[ext_resource type="Script" path="res://UI/HealthUI.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://7uhcli2ilhpt" path="res://UI/HeartUIEmpty.png" id="2"]
[ext_resource type="Texture2D" uid="uid://dltt4a7gu7so4" path="res://UI/HeartUIFull.png" id="3"]
[node name="HealthUI" type="Control"]
layout_mode = 3
anchors_preset = 0
offset_left = 2.0
offset_top = 2.0
offset_right = 124.0
offset_bottom = 27.0
script = ExtResource( 1 )
script = ExtResource("1")
[node name="HeartUIEmpty" type="TextureRect" parent="."]
layout_mode = 0
offset_right = 59.0
offset_bottom = 12.0
texture = ExtResource( 2 )
texture = ExtResource("2")
stretch_mode = 2
[node name="HeartUIFull" type="TextureRect" parent="."]
layout_mode = 0
offset_right = 60.0
offset_bottom = 11.0
texture = ExtResource( 3 )
expand = true
texture = ExtResource("3")
expand_mode = 1
stretch_mode = 2

View File

@ -1,32 +1,58 @@
[gd_scene load_steps=16 format=3 uid="uid://ckanm4arl1wqs"]
[gd_scene load_steps=16 format=4 uid="uid://ckanm4arl1wqs"]
[ext_resource type="PackedScene" uid="uid://b33u2ew1b5cqw" path="res://World/Bush.tscn" id="1"]
[ext_resource type="PackedScene" uid="uid://clt214vwnqrba" path="res://Player/Player.tscn" id="2"]
[ext_resource type="Texture2D" uid="uid://cti8so4muh5ky" path="res://World/GrassBackground.png" id="3"]
[ext_resource type="Texture2D" uid="uid://b8ykt4vtn46df" path="res://World/DirtTileset.png" id="4"]
[ext_resource type="Texture2D" uid="uid://yx0d4d27sbbs" path="res://World/CliffTileset.png" id="5"]
[ext_resource type="PackedScene" path="res://World/Grass.tscn" id="6"]
[ext_resource type="PackedScene" uid="uid://dr7343qje6tm5" path="res://World/Grass.tscn" id="6"]
[ext_resource type="PackedScene" path="res://touch_controls/TouchControls.tscn" id="7"]
[ext_resource type="PackedScene" uid="uid://cqhkluf5uxn11" path="res://Enemies/Bat.tscn" id="8"]
[ext_resource type="PackedScene" path="res://UI/HealthUI.tscn" id="9"]
[ext_resource type="PackedScene" uid="uid://b1uyh26kmvwq6" path="res://UI/HealthUI.tscn" id="9"]
[ext_resource type="PackedScene" uid="uid://cwjuswdufk2f7" path="res://World/Tree.tscn" id="10"]
[ext_resource type="PackedScene" path="res://Camera2D.tscn" id="11"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_vvs6n"]
texture = ExtResource("5")
0:0/0 = 0
1:0/0 = 0
2:0/0 = 0
0:1/0 = 0
0:2/0 = 0
3:0/0 = 0
4:0/0 = 0
5:0/0 = 0
5:1/0 = 0
5:2/0 = 0
5:3/0 = 0
5:4/0 = 0
5:5/0 = 0
4:5/0 = 0
3:5/0 = 0
2:5/0 = 0
1:5/0 = 0
0:5/0 = 0
0:4/0 = 0
0:3/0 = 0
[sub_resource type="TileSet" id="2"]
sources/0 = SubResource("TileSetAtlasSource_vvs6n")
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_kcrgu"]
texture = ExtResource("4")
[sub_resource type="TileSet" id="1"]
sources/0 = SubResource("TileSetAtlasSource_kcrgu")
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_vvs6n"]
texture = ExtResource("5")
[sub_resource type="TileSet" id="2"]
sources/0 = SubResource("TileSetAtlasSource_vvs6n")
[node name="World" type="Node2D"]
[node name="DirtCliffTileLayer" type="TileMapLayer" parent="."]
use_parent_material = true
tile_map_data = PackedByteArray("AAACAP3/AAAAAAAAAAABAP3/AAAAAAAAAAAAAP3/AAAAAAAAAAD///3/AAAAAAAAAAD+//3/AAAAAAAAAAD9//3/AAAAAAAAAAD8//3/AAAAAAAAAAD8//7/AAAAAAAAAAD7//7/AAAAAAAAAAD9/wAAAAAAAAAAAAABAP7/AAAAAAAAAAAAAP7/AAAAAAAAAAAAAP//AAAAAAAAAAD+/wAAAAAAAAAAAAADAP3/AAAAAAAAAAAGAP3/AAAAAAAAAAAHAP3/AAAAAAAAAAAIAP3/AAAAAAAAAAAJAP3/AAAAAAAAAAACAPz/AAACAAAAAAADAPz/AAADAAAAAAAEAPv/AAAAAAAAAAAFAPv/AAAAAAAAAAAGAPv/AAAAAAAAAAAHAPv/AAAAAAAAAAAAAPz/AAACAAAAAAABAPz/AAAFAAAAAAAEAPz/AAAEAAAAAAAFAPz/AAAFAAAAAAAGAPz/AAAFAAAAAAAHAPz/AAAAAAAAAAAIAPz/AAAEAAAAAAAJAPz/AAAAAAAAAAA=")
tile_set = SubResource("2")
[node name="Background" type="Sprite2D" parent="."]
texture_repeat = 2
position = Vector2(160, 90)
texture = ExtResource("3")
region_enabled = true
@ -44,10 +70,6 @@ tile_set = SubResource("1")
tile_set = SubResource("2")
format = 2
[node name="Layer1" type="TileMapLayer" parent="DirtCliffTileMap"]
use_parent_material = true
tile_set = SubResource("2")
[node name="Camera2D" parent="." instance=ExtResource("11")]
position = Vector2(167, 111)
@ -215,8 +237,6 @@ offset_bottom = 40.0
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="HealthUI" parent="CanvasLayer" instance=ExtResource("9")]
layout_mode = 3
anchors_preset = 0
offset_left = 0.0
offset_top = 0.0
offset_right = 56.0

View File

@ -1,27 +1,26 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=5 format=3 uid="uid://dr7343qje6tm5"]
[ext_resource path="res://World/Grass.png" type="Texture2D" id=1]
[ext_resource path="res://World/Grass.gd" type="Script" id=2]
[ext_resource path="res://Overlap/Hurtbox.tscn" type="PackedScene" id=3]
[ext_resource type="Texture2D" uid="uid://dy76k7loscspo" path="res://World/Grass.png" id="1"]
[ext_resource type="Script" path="res://World/Grass.gd" id="2"]
[ext_resource type="PackedScene" path="res://Overlap/Hurtbox.tscn" id="3"]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 7, 7 )
[sub_resource type="RectangleShape2D" id="1"]
size = Vector2(14, 14)
[node name="Grass" type="Node2D"]
script = ExtResource( 2 )
script = ExtResource("2")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource( 1 )
texture = ExtResource("1")
centered = false
offset = Vector2( -8, -8 )
offset = Vector2(-8, -8)
[node name="Hurtbox" parent="." instance=ExtResource( 3 )]
collision_layer = 8
show_hit = false
[node name="Hurtbox" parent="." instance=ExtResource("3")]
collision_mask = 2
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
position = Vector2( 8, 8 )
shape = SubResource( 1 )
position = Vector2(8, 8)
shape = SubResource("1")
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]