Skip to content

Commit

Permalink
Play klaxon when the player is targeted
Browse files Browse the repository at this point in the history
Resolves #41.
  • Loading branch information
jspahrsummers committed Aug 18, 2024
1 parent c4dc089 commit b1d44c4
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 3 deletions.
3 changes: 3 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ As mentioned before, the one stipulation is that these images aren’t to be use
- Asteroid6_d
- Asteroid6_n

[jsyd_klaxon2](https://pixabay.com/sound-effects/jsyd-klaxon2-108145/) created by jbum, licensed under the [Pixabay Content License](https://pixabay.com/service/license-summary/):
- jsyd_klaxon2_trimmed

Graphics created by [Justin Spahr-Summers](https://github.com/jspahrsummers) for this project, using [Midjourney](https://www.midjourney.com/):
- icon
- planet landing images
Expand Down
7 changes: 6 additions & 1 deletion actors/player.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[gd_scene load_steps=9 format=3 uid="uid://cxlg0yj8cjbrf"]
[gd_scene load_steps=10 format=3 uid="uid://cxlg0yj8cjbrf"]

[ext_resource type="Script" path="res://actors/player.gd" id="1_qxs3b"]
[ext_resource type="PackedScene" uid="uid://d1kbmfvjs6nrv" path="res://screens/landing/landing.tscn" id="2_2bp8c"]
[ext_resource type="AudioStream" uid="uid://b5h867m6j0kb2" path="res://screens/landing/audio/LandingGear.ogg" id="2_lqyst"]
[ext_resource type="Script" path="res://mechanics/economy/bank_account.gd" id="3_0316y"]
[ext_resource type="Script" path="res://mechanics/time/calendar.gd" id="4_x2dfd"]
[ext_resource type="Script" path="res://mechanics/missions/mission_controller.gd" id="6_502td"]
[ext_resource type="AudioStream" uid="uid://dxusa0iwscvln" path="res://fx/jsyd_klaxon2_trimmed.mp3" id="7_16rdj"]

[sub_resource type="Resource" id="Resource_bycam"]
script = ExtResource("3_0316y")
Expand Down Expand Up @@ -43,4 +44,8 @@ current = true
[node name="MissionController" type="Node3D" parent="." groups=["saveable"]]
script = ExtResource("6_502td")

[node name="TargetedSound" type="AudioStreamPlayer" parent="."]
stream = ExtResource("7_16rdj")
volume_db = -10.0

[connection signal="landed" from="." to="MissionController" method="_on_player_landed"]
Binary file added fx/jsyd_klaxon2_trimmed.mp3
Binary file not shown.
19 changes: 19 additions & 0 deletions fx/jsyd_klaxon2_trimmed.mp3.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[remap]

importer="mp3"
type="AudioStreamMP3"
uid="uid://dxusa0iwscvln"
path="res://.godot/imported/jsyd_klaxon2_trimmed.mp3-389baff25b014821794df822381e3108.mp3str"

[deps]

source_file="res://fx/jsyd_klaxon2_trimmed.mp3"
dest_files=["res://.godot/imported/jsyd_klaxon2_trimmed.mp3-389baff25b014821794df822381e3108.mp3str"]

[params]

loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
6 changes: 6 additions & 0 deletions mechanics/combat/combat_object.gd
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class_name CombatObject
## The root must be a [Node3D].
@export var destruction: PackedScene

## An optional sound to play when this object is targeted by another.
@export var targeted_sound: AudioStreamPlayer

## The hull of the object.
##
## Connect to [signal Hull.hull_destroyed] to be notified when the CombatObject is destroyed.
Expand Down Expand Up @@ -74,6 +77,9 @@ func add_targeted_by(targeting_system: TargetingSystem) -> void:
self._targeted_by.push_back(targeting_system)
self.targeted_by_changed.emit(self)

if self.targeted_sound:
self.targeted_sound.play()

## Removes from the list of [TArgetingSystem]s targeting this object.
##
## This [b]must[/b] only be called after a matching [method add_targeted_by] call.
Expand Down
7 changes: 5 additions & 2 deletions screens/game/game.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ script = ExtResource("11_ag0i7")
max_volume = 10.0
commodities = {}

[sub_resource type="Resource" id="Resource_o3687"]
[sub_resource type="Resource" id="Resource_u4eq6"]
resource_local_to_scene = true
script = ExtResource("13_q2g24")
max_fuel = 6.0
Expand Down Expand Up @@ -180,7 +180,10 @@ hull = SubResource("Resource_ffax2")
shield = SubResource("Resource_75c8j")
battery = SubResource("Resource_xpwk4")
cargo_hold = SubResource("Resource_bsv1l")
hyperdrive = SubResource("Resource_o3687")
hyperdrive = SubResource("Resource_u4eq6")

[node name="CombatObject" parent="HyperspaceSceneSwitcher/Sol/PlayerCorvette" index="3" node_paths=PackedStringArray("targeted_sound")]
targeted_sound = NodePath("../Player/TargetedSound")

[node name="HyperdriveSystem" type="Node3D" parent="HyperspaceSceneSwitcher/Sol/PlayerCorvette"]
script = ExtResource("16_6olqp")
Expand Down

0 comments on commit b1d44c4

Please sign in to comment.