diff --git a/assets/sfx/shoot.wav b/assets/sfx/shoot.wav new file mode 100644 index 0000000..0e4dcdb Binary files /dev/null and b/assets/sfx/shoot.wav differ diff --git a/assets/sfx/shoot.wav.import b/assets/sfx/shoot.wav.import new file mode 100644 index 0000000..697edf0 --- /dev/null +++ b/assets/sfx/shoot.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://cg6v2xvf4jkkv" +path="res://.godot/imported/shoot.wav-e9bec753846e12fa31bfb2e7cf2b2288.sample" + +[deps] + +source_file="res://assets/sfx/shoot.wav" +dest_files=["res://.godot/imported/shoot.wav-e9bec753846e12fa31bfb2e7cf2b2288.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/ship.tscn b/scenes/ship.tscn index 265427e..f67d734 100644 --- a/scenes/ship.tscn +++ b/scenes/ship.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=3 format=3 uid="uid://cbo47ftx0vcro"] +[gd_scene load_steps=4 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"] [node name="Ship" type="CharacterBody2D" groups=["ship"]] collision_mask = 2 @@ -22,7 +23,7 @@ position = Vector2(0, -1) polygon = PackedVector2Array(-3, -31, 4, -31, 32, 28, 32, 33, 28, 33, 1, 16, -24, 33, -32, 33, -32, 27) [node name="ShotCooldown" type="Timer" parent="."] -wait_time = 2.0 +wait_time = 0.75 one_shot = true [node name="Gun" type="Marker2D" parent="."] @@ -30,4 +31,7 @@ position = Vector2(0, -33) [node name="Projectiles" type="Node" parent="."] +[node name="ShootSound" type="AudioStreamPlayer" parent="."] +stream = ExtResource("3_kvryg") + [connection signal="timeout" from="ShotCooldown" to="." method="_on_shot_cooldown_timeout"] diff --git a/scripts/ship.gd b/scripts/ship.gd index ef1a755..6071f06 100644 --- a/scripts/ship.gd +++ b/scripts/ship.gd @@ -38,6 +38,7 @@ func fire_gun(pos : Vector2, rot : float) -> void: bullet.position = pos bullet.rotation = rot $Projectiles.add_child(bullet) + $ShootSound.play() can_shoot = false $ShotCooldown.start()