From c7ce3be782c2fa0c5c244f7596f2b1e455854eab Mon Sep 17 00:00:00 2001 From: Melon Bread Date: Sun, 12 May 2024 01:03:18 -0400 Subject: [PATCH] Player crash when hit comet --- assets/sfx/explosion.wav | Bin 0 -> 6413 bytes assets/sfx/explosion.wav.import | 24 +++++++++++++ scenes/comet.gd | 8 +++++ scenes/comet.tscn | 2 ++ scenes/ship.tscn | 61 +++++++++++++++++++++++++++++++- scripts/ship.gd | 4 +++ 6 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 assets/sfx/explosion.wav create mode 100644 assets/sfx/explosion.wav.import diff --git a/assets/sfx/explosion.wav b/assets/sfx/explosion.wav new file mode 100644 index 0000000000000000000000000000000000000000..323a0ac27e878c9963429df60b6f0c23ff724825 GIT binary patch literal 6413 zcmai1Ns}DcafS|#@X@~6H{X3x_-ZSHT1d+TKoS^WFl*2BzEySY`(Cg1y{mff>F(Kp z0R|ueLZl+7B_uh*k`=o6;ve9D;#V_(Ov#S$H!)RR{j&1q@@3}hhyU`?M}P6RckVp- z{`QA0l>WQFx^w5wci`V&|NWht|L@%S%R7xKUHz}WxpU_sd9v5&7wzFL_KS_3(jNdv zC78lJwI+kg`q7*;pYB@&IgXd#8$1(iiTCi(ggqYivT#e!?7n zDb?D^FSH=pghBX|lP{d>tY*G^rB^^}^0=8l|9U#z+isJ2bDPi`NPhKkv)dn%?FXdP z`SDN3XfMisukzkx^IbNp&aXF|ZEnDN`kAsm+4O}I;&FH1`^}mygza3~{n!8ecOzdc zL&SeLZ1|hEIcOZDE#vU}wQgH7PQ=B7-RstmuJ4ZG;sB&5ShdWz@uG3Xbiem7+j!z1 z4yN9G;4~jx;|8#?7vCHlUcKW_^5wfnl$ zTIt|q$xHuMIH58dOg^AFdjkT(YV%Ist##!I6|tdO(n5kP-8qnE`C zKO6MS>ivU*H><1hdG^_A(O=h*oZO=N6)V?wfPL(lDUNY>t2-YkcPke-akNlAs=dB+ zu@@)HFIhF~cLetq4%n<8;-?{g!jC8P;y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/sfx/explosion.wav.import b/assets/sfx/explosion.wav.import new file mode 100644 index 0000000..d45a9b3 --- /dev/null +++ b/assets/sfx/explosion.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://cycpanck51dqd" +path="res://.godot/imported/explosion.wav-e1f35b1a1dc4bf25a23a1f22f1673be5.sample" + +[deps] + +source_file="res://assets/sfx/explosion.wav" +dest_files=["res://.godot/imported/explosion.wav-e1f35b1a1dc4bf25a23a1f22f1673be5.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/scenes/comet.gd b/scenes/comet.gd index 1a79093..cbafd72 100644 --- a/scenes/comet.gd +++ b/scenes/comet.gd @@ -12,3 +12,11 @@ func _ready() -> void: func _physics_process(delta: float) -> void: rotate(deg_to_rad(rotaion_direction * rotation_speed * delta)) + + + + +func _on_body_entered(body: Node2D) -> void: + print(body) + if body.is_in_group("ship"): + body.crash() diff --git a/scenes/comet.tscn b/scenes/comet.tscn index 0241d65..2a59d20 100644 --- a/scenes/comet.tscn +++ b/scenes/comet.tscn @@ -11,3 +11,5 @@ texture = ExtResource("1_6q67h") [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] polygon = PackedVector2Array(19, -27, 22, -25, 25, -24, 27, -21, 31, -17, 32, -3, 32, 27, 27, 30, -8, 29, -17, 28, -25, 26, -32, 22, -32, 18, -23, 8, -20, 7, -21, 2, -29, -17, -29, -26, -27, -29, -25, -32, -14, -32, 0, -30) + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/scenes/ship.tscn b/scenes/ship.tscn index f67d734..4b999da 100644 --- a/scenes/ship.tscn +++ b/scenes/ship.tscn @@ -1,8 +1,59 @@ -[gd_scene load_steps=4 format=3 uid="uid://cbo47ftx0vcro"] +[gd_scene load_steps=8 format=3 uid="uid://cbo47ftx0vcro"] [ext_resource type="Script" path="res://scripts/ship.gd" id="1_japvq"] [ext_resource type="Texture2D" uid="uid://qcnuvee2jcp0" path="res://assets/img/ship.png" id="1_ymcdl"] [ext_resource type="AudioStream" uid="uid://cg6v2xvf4jkkv" path="res://assets/sfx/shoot.wav" id="3_kvryg"] +[ext_resource type="AudioStream" uid="uid://cycpanck51dqd" path="res://assets/sfx/explosion.wav" id="4_gdodt"] + +[sub_resource type="Animation" id="Animation_ctlro"] +resource_name = "crash" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("CrashSound:playing") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} +tracks/1/type = "method" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath(".") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0.6), +"transitions": PackedFloat32Array(1), +"values": [{ +"args": [], +"method": &"queue_free" +}] +} + +[sub_resource type="Animation" id="Animation_qfhr1"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("CrashSound:playing") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_3jmf3"] +_data = { +"RESET": SubResource("Animation_qfhr1"), +"crash": SubResource("Animation_ctlro") +} [node name="Ship" type="CharacterBody2D" groups=["ship"]] collision_mask = 2 @@ -34,4 +85,12 @@ position = Vector2(0, -33) [node name="ShootSound" type="AudioStreamPlayer" parent="."] stream = ExtResource("3_kvryg") +[node name="CrashSound" type="AudioStreamPlayer" parent="."] +stream = ExtResource("4_gdodt") + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +libraries = { +"": SubResource("AnimationLibrary_3jmf3") +} + [connection signal="timeout" from="ShotCooldown" to="." method="_on_shot_cooldown_timeout"] diff --git a/scripts/ship.gd b/scripts/ship.gd index b005e87..7c9f954 100644 --- a/scripts/ship.gd +++ b/scripts/ship.gd @@ -42,5 +42,9 @@ func fire_gun(pos : Vector2, rot : float) -> void: can_shoot = false $ShotCooldown.start() +func crash(): + $AnimationPlayer.play("crash") + + func _on_shot_cooldown_timeout() -> void: can_shoot = true