summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLogan <logan@cflip.net>2023-02-01 17:44:17 -0700
committerLogan <logan@cflip.net>2023-02-01 17:44:17 -0700
commitdd91a66238b1df039321c9a11e7c038e50b45c21 (patch)
tree29a8c79a5155a0f9e7fb4e88f80ebdf7bbad5bda
parent0d0be8268275ca42dae0899e405bcc000c445a20 (diff)
Added music scene singleton
-rw-r--r--project.godot1
-rw-r--r--scenes/audio.tscn10
-rw-r--r--scenes/level.tscn5
-rw-r--r--scenes/mainmenu.tscn15
-rw-r--r--scripts/global_variables.gd7
-rw-r--r--scripts/mainmenu.gd7
-rw-r--r--scripts/optionsmenu.gd14
-rw-r--r--scripts/splashscreen.gd8
-rw-r--r--sound/announcer_mainmenu.oggbin0 -> 52681 bytes
-rw-r--r--sound/announcer_mainmenu.ogg.import15
-rw-r--r--sound/unused_music.oggbin0 -> 847932 bytes
-rw-r--r--sound/unused_music.ogg.import15
12 files changed, 83 insertions, 14 deletions
diff --git a/project.godot b/project.godot
index ca6a54f..fbc8bd1 100644
--- a/project.godot
+++ b/project.godot
@@ -17,6 +17,7 @@ config/icon="res://textures/basketball.png"
[autoload]
global_variables="*res://scripts/global_variables.gd"
+Audio="*res://scenes/audio.tscn"
[display]
diff --git a/scenes/audio.tscn b/scenes/audio.tscn
new file mode 100644
index 0000000..a6c0cf7
--- /dev/null
+++ b/scenes/audio.tscn
@@ -0,0 +1,10 @@
+[gd_scene load_steps=2 format=2]
+
+[ext_resource path="res://sound/unused_music.ogg" type="AudioStream" id=1]
+
+[node name="Audio" type="Node"]
+pause_mode = 2
+
+[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
+stream = ExtResource( 1 )
+volume_db = -20.0
diff --git a/scenes/level.tscn b/scenes/level.tscn
index c071819..43f5689 100644
--- a/scenes/level.tscn
+++ b/scenes/level.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=10 format=2]
+[gd_scene load_steps=11 format=2]
[ext_resource path="res://textures/court_lines.png" type="Texture" id=1]
[ext_resource path="res://scenes/hoop.tscn" type="PackedScene" id=2]
@@ -6,6 +6,7 @@
[ext_resource path="res://scenes/interface.tscn" type="PackedScene" id=4]
[ext_resource path="res://textures/court_tile.png" type="Texture" id=5]
[ext_resource path="res://scripts/camera.gd" type="Script" id=6]
+[ext_resource path="res://scenes/audio.tscn" type="PackedScene" id=7]
[sub_resource type="LineShape2D" id=1]
d = 10.0
@@ -81,6 +82,8 @@ position = Vector2( 163, 37 )
[node name="Basketball" parent="." instance=ExtResource( 3 )]
position = Vector2( 123, 73 )
+[node name="Audio" parent="." instance=ExtResource( 7 )]
+
[connection signal="score" from="Hoop" to="Interface" method="_on_Hoop_score"]
[connection signal="score" from="Hoop" to="Basketball" method="_on_Hoop_score"]
[connection signal="reset" from="Basketball" to="Camera2D" method="_on_Basketball_reset"]
diff --git a/scenes/mainmenu.tscn b/scenes/mainmenu.tscn
index f3a0776..492435a 100644
--- a/scenes/mainmenu.tscn
+++ b/scenes/mainmenu.tscn
@@ -1,6 +1,9 @@
-[gd_scene load_steps=2 format=2]
+[gd_scene load_steps=5 format=2]
[ext_resource path="res://scripts/mainmenu.gd" type="Script" id=1]
+[ext_resource path="res://sound/announcer_mainmenu.ogg" type="AudioStream" id=2]
+[ext_resource path="res://sound/unused_music.ogg" type="AudioStream" id=3]
+[ext_resource path="res://theme_data/interface_theme.tres" type="Theme" id=4]
[node name="Menu" type="Control"]
margin_right = 214.0
@@ -74,6 +77,16 @@ margin_right = 100.0
margin_bottom = 152.0
text = "Quit"
+[node name="MusicAudio" type="AudioStreamPlayer" parent="."]
+stream = ExtResource( 3 )
+volume_db = -30.0
+stream_paused = true
+
+[node name="AnnouncerAudio" type="AudioStreamPlayer" parent="."]
+stream = ExtResource( 2 )
+volume_db = -20.0
+autoplay = true
+
[connection signal="pressed" from="Control/VBoxContainer/StartButton" to="." method="_on_StartButton_pressed"]
[connection signal="pressed" from="Control/VBoxContainer/LeaderboardButton" to="." method="_on_LeaderboardButton_pressed"]
[connection signal="pressed" from="Control/VBoxContainer/HelpButton" to="." method="_on_HelpButton_pressed"]
diff --git a/scripts/global_variables.gd b/scripts/global_variables.gd
index a5d0fd5..f52c06b 100644
--- a/scripts/global_variables.gd
+++ b/scripts/global_variables.gd
@@ -1,12 +1,13 @@
extends Node
+var startup : bool
var score = 0
var timer_zero = false
# Audio Settings
-var volume_master = 50
+var volume_master = 0
var volume_master_enabled = true
-var volume_music = 50
+var volume_music = 0
var volume_music_enabled = true
-var volume_sfx = 50
+var volume_sfx = 0
var volume_sfx_enabled = true
diff --git a/scripts/mainmenu.gd b/scripts/mainmenu.gd
index d63d1be..258760f 100644
--- a/scripts/mainmenu.gd
+++ b/scripts/mainmenu.gd
@@ -1,6 +1,10 @@
extends Control
-
+func _ready():
+ if global_variables.startup:
+ global_variables.startup = false
+ $AnnouncerAudio.play()
+ $"/root/Audio/AudioStreamPlayer".play()
func _on_StartButton_pressed():
get_tree().change_scene("res://scenes/level.tscn")
@@ -13,7 +17,6 @@ func _on_HelpButton_pressed():
func _on_OptionsButton_pressed():
add_child(preload("res://scenes/optionsmenu.tscn").instance())
-
func _on_CreditsButton_pressed():
pass
diff --git a/scripts/optionsmenu.gd b/scripts/optionsmenu.gd
index 6951425..7c6dbb9 100644
--- a/scripts/optionsmenu.gd
+++ b/scripts/optionsmenu.gd
@@ -2,20 +2,20 @@ extends Control
func _ready():
# When scene is instanced, load the settings from singleton
- $Control/VBoxContainer/GridContainer/VolumeMasterContainer/VolumeMasterValue.text = str(global_variables.volume_master) + "%"
+ $Control/VBoxContainer/GridContainer/VolumeMasterContainer/VolumeMasterValue.text = str(global_variables.volume_master + 50) + "%"
$Control/VBoxContainer/GridContainer/VolumeMasterContainer/VolumeMasterSlider.value = global_variables.volume_master
- $Control/VBoxContainer/GridContainer/VolumeMusicContainer/VolumeMusicValue.text = str(global_variables.volume_music) + "%"
+ $Control/VBoxContainer/GridContainer/VolumeMusicContainer/VolumeMusicValue.text = str(global_variables.volume_music + 50) + "%"
$Control/VBoxContainer/GridContainer/VolumeMusicContainer/VolumeMusicSlider.value = global_variables.volume_music
- $Control/VBoxContainer/GridContainer/VolumeSFXContainer/VolumeSFXValue.text = str(global_variables.volume_sfx) + "%"
+ $Control/VBoxContainer/GridContainer/VolumeSFXContainer/VolumeSFXValue.text = str(global_variables.volume_sfx + 50) + "%"
$Control/VBoxContainer/GridContainer/VolumeSFXContainer/VolumeSFXSlider.value = global_variables.volume_sfx
- $Control/VBoxContainer/GridContainer/FullscreenCheckBox.pressed = OS.window_fullscreen
+ $Control/VBoxContainer/GridContainer/FullscreenCheckButton.set_pressed_no_signal(OS.window_fullscreen)
func _on_ReturnButton_pressed():
queue_free()
func _on_VolumeMasterSlider_value_changed(value):
global_variables.volume_master = value
- $Control/VBoxContainer/GridContainer/VolumeMasterContainer/VolumeMasterValue.text = str(value) + "%"
+ $Control/VBoxContainer/GridContainer/VolumeMasterContainer/VolumeMasterValue.text = str(value + 50) + "%"
if value == $Control/VBoxContainer/GridContainer/VolumeMasterContainer/VolumeMasterSlider.min_value:
global_variables.volume_music_enabled = false
else:
@@ -23,7 +23,7 @@ func _on_VolumeMasterSlider_value_changed(value):
func _on_VolumeMusicSlider_value_changed(value):
global_variables.volume_music = value
- $Control/VBoxContainer/GridContainer/VolumeMusicContainer/VolumeMusicValue.text = str(value) + "%"
+ $Control/VBoxContainer/GridContainer/VolumeMusicContainer/VolumeMusicValue.text = str(value + 50) + "%"
if value == $Control/VBoxContainer/GridContainer/VolumeMusicContainer/VolumeMusicSlider.min_value:
global_variables.volume_music_enabled = false
else:
@@ -31,7 +31,7 @@ func _on_VolumeMusicSlider_value_changed(value):
func _on_VolumeSFXSlider_value_changed(value):
global_variables.volume_sfx = value
- $Control/VBoxContainer/GridContainer/VolumeSFXContainer/VolumeSFXValue.text = str(value) + "%"
+ $Control/VBoxContainer/GridContainer/VolumeSFXContainer/VolumeSFXValue.text = str(value + 50) + "%"
if value == $Control/VBoxContainer/GridContainer/VolumeSFXContainer/VolumeSFXSlider.min_value:
global_variables.volume_sfx_enabled = false
else:
diff --git a/scripts/splashscreen.gd b/scripts/splashscreen.gd
index a78d5f7..01291e9 100644
--- a/scripts/splashscreen.gd
+++ b/scripts/splashscreen.gd
@@ -1,7 +1,15 @@
extends Node
func _ready():
+ global_variables.startup = true
$AnimationPlayer.play("splashscreen")
func _on_AnimationPlayer_animation_finished(_splashscreen):
+ change_scene()
+
+func _input(event):
+ if event.is_action_pressed("escape"):
+ change_scene()
+
+func change_scene():
get_tree().change_scene("res://scenes/mainmenu.tscn")
diff --git a/sound/announcer_mainmenu.ogg b/sound/announcer_mainmenu.ogg
new file mode 100644
index 0000000..dc502c8
--- /dev/null
+++ b/sound/announcer_mainmenu.ogg
Binary files differ
diff --git a/sound/announcer_mainmenu.ogg.import b/sound/announcer_mainmenu.ogg.import
new file mode 100644
index 0000000..eaa034b
--- /dev/null
+++ b/sound/announcer_mainmenu.ogg.import
@@ -0,0 +1,15 @@
+[remap]
+
+importer="ogg_vorbis"
+type="AudioStreamOGGVorbis"
+path="res://.import/announcer_mainmenu.ogg-1d6288e957f848c57ecf38978cbe9dd8.oggstr"
+
+[deps]
+
+source_file="res://sound/announcer_mainmenu.ogg"
+dest_files=[ "res://.import/announcer_mainmenu.ogg-1d6288e957f848c57ecf38978cbe9dd8.oggstr" ]
+
+[params]
+
+loop=false
+loop_offset=0
diff --git a/sound/unused_music.ogg b/sound/unused_music.ogg
new file mode 100644
index 0000000..64a75b5
--- /dev/null
+++ b/sound/unused_music.ogg
Binary files differ
diff --git a/sound/unused_music.ogg.import b/sound/unused_music.ogg.import
new file mode 100644
index 0000000..6c4fad4
--- /dev/null
+++ b/sound/unused_music.ogg.import
@@ -0,0 +1,15 @@
+[remap]
+
+importer="ogg_vorbis"
+type="AudioStreamOGGVorbis"
+path="res://.import/unused_music.ogg-872b37fc70b3a11dc9e491985c9e8436.oggstr"
+
+[deps]
+
+source_file="res://sound/unused_music.ogg"
+dest_files=[ "res://.import/unused_music.ogg-872b37fc70b3a11dc9e491985c9e8436.oggstr" ]
+
+[params]
+
+loop=true
+loop_offset=0