Skip to content

Commit

Permalink
Added sound when mob is squashed
Browse files Browse the repository at this point in the history
  • Loading branch information
telmotrooper committed Jun 24, 2021
1 parent 5118872 commit 202c325
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 1 deletion.
3 changes: 3 additions & 0 deletions my-3d-squash-the-creeps/GameState.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extends Node

var Audio: Node
10 changes: 9 additions & 1 deletion my-3d-squash-the-creeps/GameState.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=4 format=2]

[ext_resource path="res://art/House In a Forest Loop.ogg" type="AudioStream" id=1]
[ext_resource path="res://GameStateAudio.gd" type="Script" id=2]
[ext_resource path="res://GameState.gd" type="Script" id=3]

[node name="GameState" type="Node"]
script = ExtResource( 3 )

[node name="BGM" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 1 )
autoplay = true

[node name="Audio" type="Node" parent="."]
script = ExtResource( 2 )

[node name="AudioStreamPlayer1" type="AudioStreamPlayer" parent="Audio"]
8 changes: 8 additions & 0 deletions my-3d-squash-the-creeps/GameStateAudio.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
extends Node

func _ready():
GameState.Audio = self

func play(file):
$AudioStreamPlayer1.stream = load(file)
$AudioStreamPlayer1.play()
1 change: 1 addition & 0 deletions my-3d-squash-the-creeps/Mob.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func initiliaze(start_position, player_position):

func squash():
emit_signal("squashed")
GameState.Audio.play("res://art/slimejump.ogg")
queue_free()

func _on_VisibilityNotifier_screen_exited():
Expand Down
Binary file added my-3d-squash-the-creeps/art/slimejump.ogg
Binary file not shown.
15 changes: 15 additions & 0 deletions my-3d-squash-the-creeps/art/slimejump.ogg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[remap]

importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/slimejump.ogg-10c1b3f1aa82170ca8f3f74bdb3b107c.oggstr"

[deps]

source_file="res://art/slimejump.ogg"
dest_files=[ "res://.import/slimejump.ogg-10c1b3f1aa82170ca8f3f74bdb3b107c.oggstr" ]

[params]

loop=false
loop_offset=0

0 comments on commit 202c325

Please sign in to comment.