Skip to content

Commit

Permalink
Add sounds
Browse files Browse the repository at this point in the history
Part of #22

Co-authored-by: Unfa <[email protected]>
  • Loading branch information
NathanLovato and unfa committed Sep 11, 2020
1 parent bee5a67 commit adfb4ef
Show file tree
Hide file tree
Showing 56 changed files with 630 additions and 54 deletions.
6 changes: 6 additions & 0 deletions project/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://src/Ships/Guns/LaserGun/LaserGun.gd"
}, {
"base": "AudioStreamPlayer2D",
"class": "LoopingAudioStreamPlayer2D",
"language": "GDScript",
"path": "res://src/Common/LoopingAudioStreamPlayer2D.gd"
}, {
"base": "Resource",
"class": "MapIcon",
"language": "GDScript",
Expand Down Expand Up @@ -333,6 +338,7 @@ _global_script_class_icons={
"GameWorld": "",
"Gun": "",
"LaserGun": "",
"LoopingAudioStreamPlayer2D": "",
"MapIcon": "",
"MapSprite": "",
"MapView": "",
Expand Down
29 changes: 29 additions & 0 deletions project/src/Common/LoopingAudioStreamPlayer2D.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class_name LoopingAudioStreamPlayer2D
extends AudioStreamPlayer2D

export var start: AudioStream
export var loop: AudioStream
export var tail: AudioStream

var ending := false


func _ready() -> void:
connect("finished", self, "_on_finished")


func start() -> void:
stream = start
ending = false
play()


func end() -> void:
stream = tail
ending = true


func _on_finished() -> void:
if stream == start:
stream = loop
play()
6 changes: 6 additions & 0 deletions project/src/Ships/Guns/LaserGun/LaserGun.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export var damage_per_second := 200.0
onready var laser_beam := $LaserBeam2D
onready var shooter := owner

onready var audio: LoopingAudioStreamPlayer2D = $LoopingAudioStreamPlayer2D

var is_firing := false setget set_is_firing
var collision_mask := 0 setget set_collision_mask

Expand All @@ -28,6 +30,10 @@ func set_is_firing(firing: bool) -> void:

set_physics_process(is_firing)
laser_beam.is_casting = is_firing
if is_firing:
audio.start()
else:
audio.end()


func set_collision_mask(new_mask: int) -> void:
Expand Down
15 changes: 14 additions & 1 deletion project/src/Ships/Guns/LaserGun/LaserGun.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=7 format=2]

[ext_resource path="res://src/VFX/LaserBeam/LaserBeam.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/Ships/Guns/LaserGun/LaserGun.gd" type="Script" id=2]
[ext_resource path="res://src/Ships/Guns/LaserGun/Weapons_Beam_Loop.wav" type="AudioStream" id=3]
[ext_resource path="res://src/Common/LoopingAudioStreamPlayer2D.gd" type="Script" id=4]
[ext_resource path="res://src/Ships/Guns/LaserGun/Weapons_Beam_Start.wav" type="AudioStream" id=5]
[ext_resource path="res://src/Ships/Guns/LaserGun/Weapons_Beam_End.wav" type="AudioStream" id=6]

[node name="LaserGun" type="Node2D"]
script = ExtResource( 2 )
damage_per_second = 300.0

[node name="LaserBeam2D" parent="." instance=ExtResource( 1 )]

[node name="LoopingAudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
script = ExtResource( 4 )
__meta__ = {
"_editor_description_": ""
}
start = ExtResource( 5 )
loop = ExtResource( 3 )
tail = ExtResource( 6 )
Binary file not shown.
21 changes: 21 additions & 0 deletions project/src/Ships/Guns/LaserGun/Weapons_Beam_End.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Beam_End.wav-32e717e3f50fe31462ca7fec1898ac4c.sample"

[deps]

source_file="res://src/Ships/Guns/LaserGun/Weapons_Beam_End.wav"
dest_files=[ "res://.import/Weapons_Beam_End.wav-32e717e3f50fe31462ca7fec1898ac4c.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=false
edit/loop=false
compress/mode=0
Binary file not shown.
21 changes: 21 additions & 0 deletions project/src/Ships/Guns/LaserGun/Weapons_Beam_Loop.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Beam_Loop.wav-4c1a96f95599546c8530da07ade46fd1.sample"

[deps]

source_file="res://src/Ships/Guns/LaserGun/Weapons_Beam_Loop.wav"
dest_files=[ "res://.import/Weapons_Beam_Loop.wav-4c1a96f95599546c8530da07ade46fd1.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=false
edit/loop=true
compress/mode=0
Binary file not shown.
21 changes: 21 additions & 0 deletions project/src/Ships/Guns/LaserGun/Weapons_Beam_Start.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Beam_Start.wav-dbf8e9f3a070bc30af6d8981dadf4208.sample"

[deps]

source_file="res://src/Ships/Guns/LaserGun/Weapons_Beam_Start.wav"
dest_files=[ "res://.import/Weapons_Beam_Start.wav-dbf8e9f3a070bc30af6d8981dadf4208.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=false
edit/loop=false
compress/mode=0
9 changes: 7 additions & 2 deletions project/src/Ships/Guns/Projectiles/PlasmaShot.tscn
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=9 format=2]

[ext_resource path="res://src/Ships/Guns/Projectiles/Projectile.gd" type="Script" id=1]
[ext_resource path="res://assets/world/plasma_ball.png" type="Texture" id=2]
[ext_resource path="res://src/VFX/Shaders/glow_sprite.shader" type="Shader" id=3]
[ext_resource path="res://src/VFX/DistortionEmitter.tscn" type="PackedScene" id=4]
[ext_resource path="res://src/Ships/Guns/Projectiles/Weapons_Plasma_Shot_01.wav" type="AudioStream" id=5]

[sub_resource type="ShaderMaterial" id=1]
shader = ExtResource( 3 )
shader_param/alpha_intensity_front = 0.5
shader_param/tint_front = Color( 0.972549, 0.92549, 0.92549, 1 )
shader_param/alpha_intensity_back = 3.0
shader_param/alpha_intensity_back = 1.39583
shader_param/tint_back = Color( 0.94902, 0.054902, 0.054902, 1 )
shader_param/blend_amount = 1.0
shader_param/fade_amount = 1.0
Expand Down Expand Up @@ -65,3 +66,7 @@ update_scale = false

[node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="."]
scale = Vector2( 2.47902, 2.47902 )

[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource( 5 )
attenuation = 0.535888
13 changes: 13 additions & 0 deletions project/src/Ships/Guns/Projectiles/Projectile.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
class_name Projectile
extends KinematicBody2D

const _AUDIO_SAMPLES = [
preload("Weapons_Plasma_Shot_01.wav"),
preload("Weapons_Plasma_Shot_02.wav"),
preload("Weapons_Plasma_Shot_03.wav"),
preload("Weapons_Plasma_Shot_04.wav"),
preload("Weapons_Plasma_Shot_05.wav"),
preload("Weapons_Plasma_Shot_06.wav"),
]

export var speed := 1650.0
export var damage := 10.0
export var distortion_emitter: PackedScene
Expand All @@ -18,6 +27,7 @@ onready var player := $AnimationPlayer
onready var remote_transform := $DistortionTransform
onready var visibility_notifier: VisibilityNotifier2D = $VisibilityNotifier2D
onready var collider: CollisionShape2D = $CollisionShape2D
onready var audio: AudioStreamPlayer2D = $AudioStreamPlayer2D


func _ready() -> void:
Expand Down Expand Up @@ -49,6 +59,9 @@ func appear() -> void:
)
tween.start()

audio.stream = _AUDIO_SAMPLES[randi() % _AUDIO_SAMPLES.size()]
audio.play()


func die() -> void:
self.is_active = false
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Plasma_Shot_01.wav-19aa5dfb80aee211e0242a8505200d7d.sample"

[deps]

source_file="res://src/Ships/Guns/Projectiles/Weapons_Plasma_Shot_01.wav"
dest_files=[ "res://.import/Weapons_Plasma_Shot_01.wav-19aa5dfb80aee211e0242a8505200d7d.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=false
edit/loop=false
compress/mode=0
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Plasma_Shot_02.wav-60ca603482ac0d7479dd36ce8abbe398.sample"

[deps]

source_file="res://src/Ships/Guns/Projectiles/Weapons_Plasma_Shot_02.wav"
dest_files=[ "res://.import/Weapons_Plasma_Shot_02.wav-60ca603482ac0d7479dd36ce8abbe398.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=false
edit/loop=false
compress/mode=0
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Plasma_Shot_03.wav-0b213f9e22580f7be0fff4ae33beb7cd.sample"

[deps]

source_file="res://src/Ships/Guns/Projectiles/Weapons_Plasma_Shot_03.wav"
dest_files=[ "res://.import/Weapons_Plasma_Shot_03.wav-0b213f9e22580f7be0fff4ae33beb7cd.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=false
edit/loop=false
compress/mode=0
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Plasma_Shot_04.wav-e841366e01045cb71ba23252ae37bbdc.sample"

[deps]

source_file="res://src/Ships/Guns/Projectiles/Weapons_Plasma_Shot_04.wav"
dest_files=[ "res://.import/Weapons_Plasma_Shot_04.wav-e841366e01045cb71ba23252ae37bbdc.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=false
edit/loop=false
compress/mode=0
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Plasma_Shot_05.wav-e80a2baefc32f2be9abfbc71af20ebe4.sample"

[deps]

source_file="res://src/Ships/Guns/Projectiles/Weapons_Plasma_Shot_05.wav"
dest_files=[ "res://.import/Weapons_Plasma_Shot_05.wav-e80a2baefc32f2be9abfbc71af20ebe4.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=false
edit/loop=false
compress/mode=0
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/Weapons_Plasma_Shot_06.wav-08aa0680cbdb08a88aec0190a13bd3ea.sample"

[deps]

source_file="res://src/Ships/Guns/Projectiles/Weapons_Plasma_Shot_06.wav"
dest_files=[ "res://.import/Weapons_Plasma_Shot_06.wav-08aa0680cbdb08a88aec0190a13bd3ea.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=false
edit/loop=false
compress/mode=0
Binary file added project/src/Ships/Player/Minig_Swallow.wav
Binary file not shown.
21 changes: 21 additions & 0 deletions project/src/Ships/Player/Minig_Swallow.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/Minig_Swallow.wav-b5526468481d37b809925476131fc2b0.sample"

[deps]

source_file="res://src/Ships/Player/Minig_Swallow.wav"
dest_files=[ "res://.import/Minig_Swallow.wav-b5526468481d37b809925476131fc2b0.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=false
edit/loop=false
compress/mode=0
Binary file added project/src/Ships/Player/Mining_Unload.wav
Binary file not shown.
21 changes: 21 additions & 0 deletions project/src/Ships/Player/Mining_Unload.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/Mining_Unload.wav-11877314e8676e182767b49cb0b5d252.sample"

[deps]

source_file="res://src/Ships/Player/Mining_Unload.wav"
dest_files=[ "res://.import/Mining_Unload.wav-11877314e8676e182767b49cb0b5d252.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=false
edit/loop=false
compress/mode=0
Loading

0 comments on commit adfb4ef

Please sign in to comment.