diff --git a/assets/audio/cannon.mp3 b/assets/audio/cannon.mp3 new file mode 100644 index 0000000..1abad87 Binary files /dev/null and b/assets/audio/cannon.mp3 differ diff --git a/assets/audio/cannon.mp3.import b/assets/audio/cannon.mp3.import new file mode 100644 index 0000000..09bbfae --- /dev/null +++ b/assets/audio/cannon.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://bx4oba7yo6duu" +path="res://.godot/imported/cannon.mp3-518b9fd6fe08132381dbe692630b67d0.mp3str" + +[deps] + +source_file="res://assets/audio/cannon.mp3" +dest_files=["res://.godot/imported/cannon.mp3-518b9fd6fe08132381dbe692630b67d0.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/scenes/towers/cannon_1.tscn b/scenes/towers/cannon_1.tscn index 4eb8290..fb9b0fe 100644 --- a/scenes/towers/cannon_1.tscn +++ b/scenes/towers/cannon_1.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=13 format=3 uid="uid://bexddlltacp6k"] +[gd_scene load_steps=14 format=3 uid="uid://bexddlltacp6k"] [ext_resource type="Script" path="res://scripts/towers/tower.gd" id="1_decej"] +[ext_resource type="AudioStream" uid="uid://bx4oba7yo6duu" path="res://assets/audio/cannon.mp3" id="3_h4ljg"] [ext_resource type="Texture2D" uid="uid://2ovf2ymtftgo" path="res://assets/spritesheets/towers/cannon-1.png" id="3_q7708"] [sub_resource type="AtlasTexture" id="AtlasTexture_3x0a2"] @@ -99,5 +100,9 @@ rotation = 1.5708 scale = Vector2(0.3, 0.3) show_percentage = false +[node name="Shoot" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource("3_h4ljg") +volume_db = -40.0 + [connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"] [connection signal="body_exited" from="Area2D" to="." method="_on_body_exited"] diff --git a/scenes/towers/cannon_2.tscn b/scenes/towers/cannon_2.tscn index 9cb5243..4d5c118 100644 --- a/scenes/towers/cannon_2.tscn +++ b/scenes/towers/cannon_2.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=14 format=3 uid="uid://dij57511gfg4t"] [ext_resource type="Script" path="res://scripts/towers/tower.gd" id="1_eyei4"] -[ext_resource type="PackedScene" uid="uid://dqa80ptcc8p70" path="res://scenes/bullets/bullet_1.tscn" id="2_r6s38"] +[ext_resource type="AudioStream" uid="uid://bx4oba7yo6duu" path="res://assets/audio/cannon.mp3" id="3_cih6o"] [ext_resource type="Texture2D" uid="uid://br7wgq61n6ufv" path="res://assets/spritesheets/towers/cannon-2.png" id="3_us71t"] [sub_resource type="AtlasTexture" id="AtlasTexture_74asi"] @@ -73,7 +73,6 @@ radius = 138.293 [node name="cannon-2" type="Node2D" groups=["Towers"]] script = ExtResource("1_eyei4") -bullet = ExtResource("2_r6s38") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] position = Vector2(-1, 0) @@ -100,5 +99,9 @@ rotation = 1.5708 scale = Vector2(0.3, 0.3) show_percentage = false +[node name="Shoot" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource("3_cih6o") +volume_db = -40.0 + [connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"] [connection signal="body_exited" from="Area2D" to="." method="_on_body_exited"] diff --git a/scenes/towers/cannon_3.tscn b/scenes/towers/cannon_3.tscn index 496f89c..196faaf 100644 --- a/scenes/towers/cannon_3.tscn +++ b/scenes/towers/cannon_3.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=14 format=3 uid="uid://mxre00inxhlf"] [ext_resource type="Script" path="res://scripts/towers/tower.gd" id="1_pa8xy"] -[ext_resource type="PackedScene" uid="uid://dqa80ptcc8p70" path="res://scenes/bullets/bullet_1.tscn" id="2_gqu6e"] +[ext_resource type="AudioStream" uid="uid://bx4oba7yo6duu" path="res://assets/audio/cannon.mp3" id="3_r4bfa"] [ext_resource type="Texture2D" uid="uid://by4hjrjfcxsdl" path="res://assets/spritesheets/towers/cannon-3.png" id="3_tjfbt"] [sub_resource type="AtlasTexture" id="AtlasTexture_roben"] @@ -73,7 +73,6 @@ radius = 138.293 [node name="cannon-3" type="Node2D" groups=["Towers"]] script = ExtResource("1_pa8xy") -bullet = ExtResource("2_gqu6e") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] position = Vector2(-1, 0) @@ -100,5 +99,9 @@ rotation = 1.5708 scale = Vector2(0.3, 0.3) show_percentage = false +[node name="Shoot" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource("3_r4bfa") +volume_db = -40.0 + [connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"] [connection signal="body_exited" from="Area2D" to="." method="_on_body_exited"] diff --git a/scripts/towers/tower.gd b/scripts/towers/tower.gd index c19e16b..e04e082 100644 --- a/scripts/towers/tower.gd +++ b/scripts/towers/tower.gd @@ -4,6 +4,7 @@ signal on_destroy(tower_placement_id) @onready var rayCast = $RayCast2D @onready var timer = $Timer +@onready var shoot = $Shoot var bullet: PackedScene = null @@ -58,6 +59,7 @@ func _physics_process(_delta): func _shoot(): if bullet: + shoot.play() var bullet_instance: Node2D = bullet.instantiate() bullet_instance.dir = rotation bullet_instance.rotation = rotation