initial sound effects and better camera pos

This commit is contained in:
mehbark 2025-05-01 17:36:09 -04:00
parent 82b10bdae5
commit e33cc17bc2
13 changed files with 125 additions and 5 deletions

28
main.gd
View file

@ -10,17 +10,37 @@ var microban_1 := "
####
"
var hist := UndoRedo.new()
@onready var camera: Camera3D = $Camera
var hist := UndoRedo.new()
@onready var board := Board.from_string(microban_1)
var player: Piece
@onready var sound: AudioStreamPlayer = $Sound
var sounds_hit := AudioStreamRandomizer.new()
func _ready() -> void:
add_child(board)
var wall_count := 0
var wall_pos_sum := Vector2.ZERO
for piece in board.pieces():
if piece.type == Piece.Type.Player:
player = piece
break
elif piece.type == Piece.Type.Wall:
wall_count += 1
wall_pos_sum += Vector2(piece.position.x, piece.position.z)
var wall_pos_mean := wall_pos_sum / wall_count
camera.position = Vector3(wall_pos_mean.x, camera.position.y, wall_pos_mean.y)
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"):
var stream := AudioStream.new()
sounds_hit.add_stream(-1, load("res://sfx/hit/"+file_name))
file_name = hit_dir.get_next()
func _input(event: InputEvent) -> void:
if event.is_action_pressed("u", true, true):
@ -57,4 +77,6 @@ func step(move: Vector2i):
hist.add_undo_method(player.undo_move())
hist.add_undo_method(box.undo_move())
hist.commit_action()
else:
sound.stream = sounds_hit
sound.play()

View file

@ -15,9 +15,11 @@ sky = SubResource("Sky_0xm2m")
[node name="Main" type="Node3D"]
script = ExtResource("1_ig7tw")
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.258819, 0.965926, 0, -0.965926, 0.258819, 0.035, 3.615, 3)
[node name="Camera" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 5, 0)
fov = 90.0
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_ig7tw")
[node name="Sound" type="AudioStreamPlayer" parent="."]

1
sfx/README.md Normal file
View file

@ -0,0 +1 @@
All by <https://kenny.nl> at the moment

Binary file not shown.

View file

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://32b05o0gs65d"
path="res://.godot/imported/impactWood_light_000.ogg-a9ff47e2e13050e4747ef0ee4c05cae4.oggvorbisstr"
[deps]
source_file="res://sfx/hit/impactWood_light_000.ogg"
dest_files=["res://.godot/imported/impactWood_light_000.ogg-a9ff47e2e13050e4747ef0ee4c05cae4.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

View file

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://b6c1870gw718w"
path="res://.godot/imported/impactWood_light_001.ogg-e572ed376077e4ef80d61ce22f371c3e.oggvorbisstr"
[deps]
source_file="res://sfx/hit/impactWood_light_001.ogg"
dest_files=["res://.godot/imported/impactWood_light_001.ogg-e572ed376077e4ef80d61ce22f371c3e.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

View file

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://qluewtosf3ac"
path="res://.godot/imported/impactWood_light_002.ogg-614ecbf6ef3c68b4bbd2df923ef7c73e.oggvorbisstr"
[deps]
source_file="res://sfx/hit/impactWood_light_002.ogg"
dest_files=["res://.godot/imported/impactWood_light_002.ogg-614ecbf6ef3c68b4bbd2df923ef7c73e.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

View file

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://bx2npa8e11tm5"
path="res://.godot/imported/impactWood_light_003.ogg-08f59967206b89ae66aaa9ee5fabdef7.oggvorbisstr"
[deps]
source_file="res://sfx/hit/impactWood_light_003.ogg"
dest_files=["res://.godot/imported/impactWood_light_003.ogg-08f59967206b89ae66aaa9ee5fabdef7.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

View file

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://bd4cu630k3blx"
path="res://.godot/imported/impactWood_light_004.ogg-b62f931cc146a1867b253bba34c89345.oggvorbisstr"
[deps]
source_file="res://sfx/hit/impactWood_light_004.ogg"
dest_files=["res://.godot/imported/impactWood_light_004.ogg-b62f931cc146a1867b253bba34c89345.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4