Added sounds

Added sounds and ambience to the project
pull/19/head
Kenney 2025-09-17 08:26:58 +07:00
parent 5776f4a805
commit 1cbec71002
27 changed files with 273 additions and 2 deletions

@ -18,6 +18,10 @@ boot_splash/bg_color=Color(0.92549, 0.92549, 0.960784, 1)
boot_splash/image="res://splash-screen.png"
config/icon="res://icon.png"
[autoload]
Audio="*res://scripts/audio.gd"
[editor]
movie_writer/movie_file="D:/Godot/recording.avi"

@ -1,4 +1,4 @@
[gd_scene load_steps=25 format=3 uid="uid://vgwrcfy1qawf"]
[gd_scene load_steps=26 format=3 uid="uid://vgwrcfy1qawf"]
[ext_resource type="Script" uid="uid://76g8ejmdibal" path="res://scripts/builder.gd" id="1_jybm7"]
[ext_resource type="Environment" uid="uid://jbptgqvstei3" path="res://scenes/main-environment.tres" id="1_yndf3"]
@ -23,6 +23,7 @@
[ext_resource type="FontFile" uid="uid://d0cxd77jybrcn" path="res://fonts/lilita_one_regular.ttf" id="16_vlub6"]
[ext_resource type="Texture2D" uid="uid://bng0d1sou7c8a" path="res://sprites/coin.png" id="17_cjamx"]
[ext_resource type="Texture2D" uid="uid://ciwbdik3tmxtp" path="res://sprites/instructions.png" id="22_pm3ni"]
[ext_resource type="AudioStream" uid="uid://wvfsgkl8qob6" path="res://sounds/ambience.ogg" id="24_y6deb"]
[sub_resource type="LabelSettings" id="LabelSettings_q176i"]
font = ExtResource("16_vlub6")
@ -111,3 +112,8 @@ offset_right = 344.0
offset_bottom = 887.0
scale = Vector2(0.5, 0.5)
texture = ExtResource("22_pm3ni")
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource("24_y6deb")
volume_db = -30.0
autoplay = true

@ -0,0 +1,42 @@
extends Node
# Code adapted from KidsCanCode
var num_players = 12
var bus = "master"
var available = [] # The available players.
var queue = [] # The queue of {path, volume} dictionaries.
func _ready():
for i in num_players:
var p = AudioStreamPlayer.new()
add_child(p)
available.append(p)
p.volume_db = -10
p.finished.connect(_on_stream_finished.bind(p))
p.bus = bus
func _on_stream_finished(stream):
available.append(stream)
func play(sound_path: String, volume_db: float = -10.0):
# Path (or multiple, separated by commas)
var sounds = sound_path.split(",")
var chosen = "res://" + sounds[randi() % sounds.size()].strip_edges()
queue.append({
"path": chosen,
"volume": volume_db
})
func _process(_delta):
if not queue.is_empty() and not available.is_empty():
var item = queue.pop_front()
var player = available.pop_front()
player.stream = load(item["path"])
player.volume_db = item["volume"]
player.pitch_scale = randf_range(0.9, 1.1)
player.play()

@ -0,0 +1 @@
uid://b6g5iasbsyq1x

@ -84,27 +84,36 @@ func action_build(gridmap_position):
if previous_tile != index:
map.cash -= structures[index].price
update_cash()
Audio.play("sounds/placement-a.ogg, sounds/placement-b.ogg, sounds/placement-c.ogg, sounds/placement-d.ogg", -20)
# Demolish (remove) a structure
func action_demolish(gridmap_position):
if Input.is_action_just_pressed("demolish"):
gridmap.set_cell_item(gridmap_position, -1)
if gridmap.get_cell_item(gridmap_position) != -1:
gridmap.set_cell_item(gridmap_position, -1)
Audio.play("sounds/removal-a.ogg, sounds/removal-b.ogg, sounds/removal-c.ogg, sounds/removal-d.ogg", -20)
# Rotates the 'cursor' 90 degrees
func action_rotate():
if Input.is_action_just_pressed("rotate"):
selector.rotate_y(deg_to_rad(90))
Audio.play("sounds/rotate.ogg", -30)
# Toggle between structures to build
func action_structure_toggle():
if Input.is_action_just_pressed("structure_next"):
index = wrap(index + 1, 0, structures.size())
Audio.play("sounds/toggle.ogg", -30)
if Input.is_action_just_pressed("structure_previous"):
index = wrap(index - 1, 0, structures.size())
Audio.play("sounds/toggle.ogg", -30)
update_structure()

Binary file not shown.

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://wvfsgkl8qob6"
path="res://.godot/imported/ambience.ogg-06f8005a28aaf7071eab8a3c7655940a.oggvorbisstr"
[deps]
source_file="res://sounds/ambience.ogg"
dest_files=["res://.godot/imported/ambience.ogg-06f8005a28aaf7071eab8a3c7655940a.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://dvmkltf62sl6d"
path="res://.godot/imported/placement-a.ogg-bdb1e41ed026dd9d40a4cf95bf46f2f8.oggvorbisstr"
[deps]
source_file="res://sounds/placement-a.ogg"
dest_files=["res://.godot/imported/placement-a.ogg-bdb1e41ed026dd9d40a4cf95bf46f2f8.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://bclwh4gkbpgc0"
path="res://.godot/imported/placement-b.ogg-d700d7e7fe0800ffc3998bbf539d723e.oggvorbisstr"
[deps]
source_file="res://sounds/placement-b.ogg"
dest_files=["res://.godot/imported/placement-b.ogg-d700d7e7fe0800ffc3998bbf539d723e.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://dlyw5vro7nndy"
path="res://.godot/imported/placement-c.ogg-0914c55e4166d68221b1f531bfaac866.oggvorbisstr"
[deps]
source_file="res://sounds/placement-c.ogg"
dest_files=["res://.godot/imported/placement-c.ogg-0914c55e4166d68221b1f531bfaac866.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://beod8l1kkkncu"
path="res://.godot/imported/placement-d.ogg-e0662b91eb0812e10f48dc671192b2e6.oggvorbisstr"
[deps]
source_file="res://sounds/placement-d.ogg"
dest_files=["res://.godot/imported/placement-d.ogg-e0662b91eb0812e10f48dc671192b2e6.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://1tf8k7b76bxv"
path="res://.godot/imported/removal-a.ogg-d917c6911910529dc9d47d7785b2e382.oggvorbisstr"
[deps]
source_file="res://sounds/removal-a.ogg"
dest_files=["res://.godot/imported/removal-a.ogg-d917c6911910529dc9d47d7785b2e382.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://dqwaqhr6r6hui"
path="res://.godot/imported/removal-b.ogg-c06a07f2ba569575112caae669ec8bc5.oggvorbisstr"
[deps]
source_file="res://sounds/removal-b.ogg"
dest_files=["res://.godot/imported/removal-b.ogg-c06a07f2ba569575112caae669ec8bc5.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://coeitccvxgdck"
path="res://.godot/imported/removal-c.ogg-d4227e081d5850200b0d7221d5e128ef.oggvorbisstr"
[deps]
source_file="res://sounds/removal-c.ogg"
dest_files=["res://.godot/imported/removal-c.ogg-d4227e081d5850200b0d7221d5e128ef.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://d0pi1p2aqvfnb"
path="res://.godot/imported/removal-d.ogg-a0f42199d9bdc9ce5fb842f46d43359d.oggvorbisstr"
[deps]
source_file="res://sounds/removal-d.ogg"
dest_files=["res://.godot/imported/removal-d.ogg-a0f42199d9bdc9ce5fb842f46d43359d.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

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

Binary file not shown.

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