Basic SFX
This commit is contained in:
parent
447566dc73
commit
0b48599dac
|
@ -7,6 +7,10 @@ var tex_judgement_text := preload("res://assets/text-4k.png")
|
|||
var tex_slide_arrow := preload("res://assets/slide-arrow-4k.png")
|
||||
var slide_trail_shadermaterial := preload("res://shaders/slidetrail.tres")
|
||||
|
||||
var snd_miss := preload("res://assets/miss.wav")
|
||||
var snd_clap := preload("res://assets/softclap.wav")
|
||||
var snd_judgement = [snd_clap, snd_clap, snd_clap, snd_clap]
|
||||
|
||||
## Constants for the overall notefield
|
||||
#var GameTheme.RADIAL_COL_ANGLES := PoolRealArray() # ideally const
|
||||
#var GameTheme.RADIAL_UNIT_VECTORS := PoolVector2Array() # ideally const
|
||||
|
@ -234,6 +238,7 @@ func make_slide_trail_mesh(note) -> ArrayMesh:
|
|||
#----------------------------------------------------------------------------------------------------------------------------------------------
|
||||
func activate_note(note, judgement):
|
||||
active_judgement_texts.append({col=note.column, judgement=judgement, time=t})
|
||||
SFXPlayer.play(SFXPlayer.Type.NON_POSITIONAL, self, snd_judgement[judgement])
|
||||
scores[note.type][judgement] += 1
|
||||
|
||||
note.time_activated = t
|
||||
|
@ -470,6 +475,7 @@ func _process(delta):
|
|||
active_judgement_texts.append({col=note.column, judgement="MISS", time=t})
|
||||
scores[note.type]["MISS"] += 1
|
||||
note.missed = true
|
||||
SFXPlayer.play(SFXPlayer.Type.NON_POSITIONAL, self, snd_miss)
|
||||
|
||||
# Clean out expired judgement texts
|
||||
# By design they will always be in order so we can ignore anything past the first index
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
extends Node
|
||||
|
||||
#const MAX_PLAYERS = 16
|
||||
#var players = []
|
||||
#
|
||||
#func _init():
|
||||
# for i in MAX_PLAYERS:
|
||||
# players.append(AudioStreamPlayer.new())
|
||||
#
|
||||
#func play():
|
||||
# pass
|
||||
|
||||
|
||||
|
||||
# https://github.com/Calinou/escape-space/blob/master/autoload/sound.gd
|
||||
enum Type {
|
||||
NON_POSITIONAL,
|
||||
POSITIONAL_2D,
|
||||
}
|
||||
|
||||
|
||||
# Plays a sound. The AudioStreamPlayer node will be added to the `parent`
|
||||
# specified as parameter.
|
||||
func play(type: int, parent: Node, stream: AudioStream, volume_db: float = 0.0, pitch_scale: float = 1.0) -> void:
|
||||
var audio_stream_player: Node
|
||||
match type:
|
||||
Type.NON_POSITIONAL:
|
||||
audio_stream_player = AudioStreamPlayer.new()
|
||||
Type.POSITIONAL_2D:
|
||||
audio_stream_player = AudioStreamPlayer2D.new()
|
||||
|
||||
parent.add_child(audio_stream_player)
|
||||
audio_stream_player.bus = "Effects"
|
||||
audio_stream_player.stream = stream
|
||||
audio_stream_player.volume_db = volume_db
|
||||
audio_stream_player.pitch_scale = pitch_scale
|
||||
audio_stream_player.play()
|
||||
audio_stream_player.connect("finished", audio_stream_player, "queue_free")
|
|
@ -49,7 +49,7 @@ grow_vertical = 2
|
|||
rect_pivot_offset = Vector2( 540, 540 )
|
||||
mouse_filter = 2
|
||||
stream = ExtResource( 2 )
|
||||
volume_db = -16.62
|
||||
volume_db = -10.92
|
||||
script = ExtResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
|
|
|
@ -31,6 +31,7 @@ Note="*res://Note.gd"
|
|||
FileLoader="*res://FileLoader.gd"
|
||||
Rules="*res://Rules.gd"
|
||||
GameTheme="*res://GameTheme.gd"
|
||||
SFXPlayer="*res://SFXPlayer.gd"
|
||||
|
||||
[debug]
|
||||
|
||||
|
|
Loading…
Reference in New Issue