more placeholder sound effects
This commit is contained in:
parent
cb2e88bf3e
commit
425053b4b2
5 changed files with 59 additions and 13 deletions
34
main.gd
34
main.gd
|
|
@ -17,8 +17,9 @@ var hist := UndoRedo.new()
|
||||||
var player: Piece
|
var player: Piece
|
||||||
|
|
||||||
@onready var sound: AudioStreamPlayer = $Sound
|
@onready var sound: AudioStreamPlayer = $Sound
|
||||||
var sounds_hit := AudioStreamRandomizer.new()
|
@onready var sounds_hit := audio_stream_randomizer_from_dir("res://sfx/hit")
|
||||||
|
@onready var sounds_undo := audio_stream_randomizer_from_dir("res://sfx/undo")
|
||||||
|
@onready var sounds_redo := audio_stream_randomizer_from_dir("res://sfx/redo")
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
add_child(board)
|
add_child(board)
|
||||||
|
|
@ -29,15 +30,6 @@ func _ready() -> void:
|
||||||
$BottomRight.aabb = board.bottom_right_aabb()
|
$BottomRight.aabb = board.bottom_right_aabb()
|
||||||
camera.position = Vector3(player.position.x, camera.position.y, player.position.z)
|
camera.position = Vector3(player.position.x, camera.position.y, player.position.z)
|
||||||
|
|
||||||
sounds_hit.random_pitch = 1.1
|
|
||||||
var hit_dir := DirAccess.open("res://sfx/hit")
|
|
||||||
hit_dir.list_dir_begin()
|
|
||||||
var file_name := hit_dir.get_next()
|
|
||||||
while file_name != "":
|
|
||||||
if file_name.ends_with("ogg"):
|
|
||||||
sounds_hit.add_stream(-1, load("res://sfx/hit/"+file_name))
|
|
||||||
file_name = hit_dir.get_next()
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
if $TopLeft.is_on_screen() and $BottomRight.is_on_screen():
|
if $TopLeft.is_on_screen() and $BottomRight.is_on_screen():
|
||||||
return
|
return
|
||||||
|
|
@ -53,9 +45,13 @@ func _input(event: InputEvent) -> void:
|
||||||
elif event.is_action_pressed("r", true, true):
|
elif event.is_action_pressed("r", true, true):
|
||||||
step(Vector2i.RIGHT)
|
step(Vector2i.RIGHT)
|
||||||
elif event.is_action_pressed("undo", true, true):
|
elif event.is_action_pressed("undo", true, true):
|
||||||
hist.undo()
|
if hist.undo():
|
||||||
|
sound.stream = sounds_undo
|
||||||
|
sound.play()
|
||||||
elif event.is_action_pressed("redo", true, true):
|
elif event.is_action_pressed("redo", true, true):
|
||||||
hist.redo()
|
if hist.redo():
|
||||||
|
sound.stream = sounds_redo
|
||||||
|
sound.play()
|
||||||
elif event.is_action_pressed("restart", true, true):
|
elif event.is_action_pressed("restart", true, true):
|
||||||
restart()
|
restart()
|
||||||
|
|
||||||
|
|
@ -81,3 +77,15 @@ func step(move: Vector2i):
|
||||||
else:
|
else:
|
||||||
sound.stream = sounds_hit
|
sound.stream = sounds_hit
|
||||||
sound.play()
|
sound.play()
|
||||||
|
|
||||||
|
func audio_stream_randomizer_from_dir(dir: String) -> AudioStreamRandomizer:
|
||||||
|
var stream := AudioStreamRandomizer.new()
|
||||||
|
stream.random_pitch = 1.1
|
||||||
|
var hit_dir := DirAccess.open(dir)
|
||||||
|
hit_dir.list_dir_begin()
|
||||||
|
var file_name := hit_dir.get_next()
|
||||||
|
while file_name != "":
|
||||||
|
if file_name.ends_with("ogg"):
|
||||||
|
stream.add_stream(-1, load(dir+"/"+file_name))
|
||||||
|
file_name = hit_dir.get_next()
|
||||||
|
return stream
|
||||||
|
|
|
||||||
BIN
sfx/redo/jingles-saxophone_15.ogg
Normal file
BIN
sfx/redo/jingles-saxophone_15.ogg
Normal file
Binary file not shown.
19
sfx/redo/jingles-saxophone_15.ogg.import
Normal file
19
sfx/redo/jingles-saxophone_15.ogg.import
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="oggvorbisstr"
|
||||||
|
type="AudioStreamOggVorbis"
|
||||||
|
uid="uid://yckyg3m66h1u"
|
||||||
|
path="res://.godot/imported/jingles-saxophone_15.ogg-75960c939c728136300eb69e1176d924.oggvorbisstr"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://sfx/redo/jingles-saxophone_15.ogg"
|
||||||
|
dest_files=["res://.godot/imported/jingles-saxophone_15.ogg-75960c939c728136300eb69e1176d924.oggvorbisstr"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=false
|
||||||
|
loop_offset=0
|
||||||
|
bpm=0
|
||||||
|
beat_count=0
|
||||||
|
bar_beats=4
|
||||||
BIN
sfx/undo/jingles-saxophone_16.ogg
Normal file
BIN
sfx/undo/jingles-saxophone_16.ogg
Normal file
Binary file not shown.
19
sfx/undo/jingles-saxophone_16.ogg.import
Normal file
19
sfx/undo/jingles-saxophone_16.ogg.import
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="oggvorbisstr"
|
||||||
|
type="AudioStreamOggVorbis"
|
||||||
|
uid="uid://cs2drft1a74sw"
|
||||||
|
path="res://.godot/imported/jingles-saxophone_16.ogg-2a826dd03c8724fa27e6b96d58aa50df.oggvorbisstr"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://sfx/undo/jingles-saxophone_16.ogg"
|
||||||
|
dest_files=["res://.godot/imported/jingles-saxophone_16.ogg-2a826dd03c8724fa27e6b96d58aa50df.oggvorbisstr"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=false
|
||||||
|
loop_offset=0
|
||||||
|
bpm=0
|
||||||
|
beat_count=0
|
||||||
|
bar_beats=4
|
||||||
Loading…
Reference in a new issue