Skip to content

Commit

Permalink
Caching! and uh yea more arrow system work
Browse files Browse the repository at this point in the history
  • Loading branch information
rayanmargham committed Nov 7, 2021
1 parent 573a4a2 commit 0bc8d1f
Show file tree
Hide file tree
Showing 11 changed files with 1,549 additions and 1,438 deletions.
36 changes: 36 additions & 0 deletions Assets/JSON&Text_Files/ResourceLocations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"Songs":
{
"FreakyMenu":
"res://Assets/Menus/Music&Sounds/freakyMenu.ogg"
},
"Sounds":
{
"cancelMenu":
"res://Assets/Menus/Music&Sounds/cancelMenu.wav",
"confirmMenu":
"res://Assets/Menus/Music&Sounds/confirmMenu.wav",
"intro3":
"res://Assets/Stages/RhythmSystem/countdown/intro3.ogg",
"intro2":
"res://Assets/Stages/RhythmSystem/countdown/intro2.ogg",
"intro1":
"res://Assets/Stages/RhythmSystem/countdown/intro1.ogg",
"LinuxSplash":
"res://Assets/Menus/Music&Sounds/LinuxSplash.wav",
"introGo":
"res://Assets/Stages/RhythmSystem/countdown/introGo.ogg",
"scrollMenu":
"res://Assets/Menus/Music&Sounds/scrollMenu.wav",
"SplashSound":
"res://Assets/Menus/Music&Sounds/SplashSound.wav",
"Alert":
"res://Assets/Menus/Music&Sounds/Alert.wav",
"first_button_hover":
"res://Misc/FirstUse/Sounds/ui_button_hover.wav",
"first_button_selected":
"res://Misc/FirstUse/Sounds/ui_button_selected.wav",
"first_done":
"res://Misc/FirstUse/Sounds/ui_done.wav"
}
}
Binary file added Assets/Menus/Music&Sounds/LinuxSplash.wav
Binary file not shown.
21 changes: 21 additions & 0 deletions Assets/Menus/Music&Sounds/LinuxSplash.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/LinuxSplash.wav-bb948bc506660f56742cf8de8b569a5a.sample"

[deps]

source_file="res://Assets/Menus/Music&Sounds/LinuxSplash.wav"
dest_files=[ "res://.import/LinuxSplash.wav-bb948bc506660f56742cf8de8b569a5a.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0
50 changes: 50 additions & 0 deletions AutoLoads/Resources.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
extends Node


# Songs
var FreakyMenu:Resource

# Sounds
var cancelMenu:Resource
var confirmMenu:Resource
var intro3:Resource
var intro2:Resource
var intro1:Resource
var LinuxSplash:Resource
var introGo:Resource
var scrollMenu:Resource
var SplashSound:Resource
var Alert:Resource
var first_button_hover:Resource
var first_button_selected:Resource
var first_done:Resource

func loadResources(JsonContainingLocations = "res://Assets/JSON&Text_Files/ResourceLocations.json"):
# you would do this in godot 4
# var json = JSON.new()
# var jsonObject = json.parse(load(JsonContainingLocations))
# var json_complete = json.get_data()
var file = File.new()
file.open(JsonContainingLocations, File.READ)
var json = file.get_as_text()
var json_complete = parse_json(json)
cancelMenu = load(json_complete.Sounds.cancelMenu)
confirmMenu = load(json_complete.Sounds.confirmMenu)
intro3 = load(json_complete.Sounds.intro3)
intro2 = load(json_complete.Sounds.intro2)
intro1 = load(json_complete.Sounds.intro1)
introGo = load(json_complete.Sounds.introGo)
scrollMenu = load(json_complete.Sounds.scrollMenu)
Alert = load(json_complete.Sounds.Alert)
func loadRequiredResources(JsonContainingLocations = "res://Assets/JSON&Text_Files/ResourceLocations.json"):
var file = File.new()
file.open(JsonContainingLocations, File.READ)
var json = file.get_as_text()
var json_complete = parse_json(json)
first_button_hover = load(json_complete.Sounds.first_button_hover)
first_button_selected = load(json_complete.Sounds.first_button_selected)
first_done = load(json_complete.Sounds.first_done)
SplashSound = load(json_complete.Sounds.SplashSound)
LinuxSplash = load(json_complete.Sounds.LinuxSplash)
func _ready():
loadRequiredResources()
108 changes: 53 additions & 55 deletions AutoLoads/SoundController.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,91 +4,89 @@ extends Node
# This Autoload is for managing sound
# and easy sound playing.
########################################
var sound_array = []
signal finished_sound
#var search_num = 0
func _ready():
pass
$GarbageCollectionTimer.connect("timeout", self, "_Garbage_Collect")

func Play_sound(sound = "SplashSound"):
func Play_sound(sound = "LinuxSplash"):
#Type the sound you want and it will search it for you

var target = null
var volume = 0.5
var temp_name = ""
match sound:
"cancelMenu":
temp_name = sound
#this are 1
target = load("res://Assets/Menus/Music&Sounds/cancelMenu.wav")
target = Resources.cancelMenu
"confirmMenu":
temp_name = sound
#this are 1
target = load("res://Assets/Menus/Music&Sounds/confirmMenu.wav")
target = Resources.confirmMenu
"intro3":
temp_name = sound
target = load("res://Assets/Stages/RhythmSystem/countdown/intro3.ogg")

target = Resources.intro3
"intro2":
temp_name = sound
target = load("res://Assets/Stages/RhythmSystem/countdown/intro2.ogg")

target = Resources.intro2
"intro1":
temp_name = sound
target = load("res://Assets/Stages/RhythmSystem/countdown/intro1.ogg")

target = Resources.intro1
"LinuxSplash":

target = Resources.LinuxSplash
volume = 5
"introGo":
temp_name = sound
target = load("res://Assets/Stages/RhythmSystem/countdown/introGo.ogg")

target = Resources.introGo
"scrollMenu":
temp_name = sound

#this are 1
target = load("res://Assets/Menus/Music&Sounds/scrollMenu.wav")
target = Resources.scrollMenu
"SplashSound":
temp_name = sound

#this are 1
volume = 20
target = load("res://Assets/Menus/Music&Sounds/SplashSound.wav")
target = Resources.SplashSound
"Alert":
target = load("res://Assets/Menus/Music&Sounds/Alert.wav")
target = Resources.Alert
# go on 30
volume = 30
"first_button_hover":
temp_name = sound
target = load("res://Misc/FirstUse/Sounds/ui_button_hover.wav")

target = Resources.first_button_hover
"first_button_selected":
temp_name = sound
target = load("res://Misc/FirstUse/Sounds/ui_button_selected.wav")

target = Resources.first_button_selected
"first_done":
temp_name = sound
target = load("res://Misc/FirstUse/Sounds/ui_done.wav")

target = Resources.first_done
_:
print("ERROR: Could not play sound: ", sound)
return
var temp_sound = AudioStreamPlayer.new()
var sound_info = []
temp_sound.stream = target
temp_sound.volume_db = volume
sound_info.append(temp_sound)
# name should be at 1 in the sound info array
# you can just search for them lol
sound_info.append(temp_name)
sound_array.append(sound_info)
add_child(temp_sound)
temp_sound.play()
yield(temp_sound,"finished")
var new_sound = AudioStreamPlayer.new()
new_sound.stream = target
add_child(new_sound)
new_sound.play()
yield(new_sound, "finished")
emit_signal("finished_sound")
remove_child(temp_sound)
sound_array.erase(sound_info)
func Stop_sound(thingtofind = "SplashSound"):
var search_num = 0
if sound_array.size() != 0:
while sound_array[search_num][1] != thingtofind and search_num <= sound_array.size():
search_num += 1
sound_array[search_num][0].stop()
sound_array.remove(search_num)

func Stop_sound(thingtofind = "Assets/Menus/Music&Sounds/LinuxSplash.wav"):
for i in get_children():
if i:
if i.name.begins_with("@"):
if i.stream == load("res://" + thingtofind):
i.stop()
func Stop_all():
var search_num = 0
if sound_array.size() != 0:
while search_num <= sound_array.size():
if sound_array[search_num][0]:
remove_child(sound_array[search_num][0])
sound_array.remove(search_num)
search_num += 1
for i in get_children():
if i:
if i.name.begins_with("@"):
i.stop()
func Set_Garbage_Collection_WaitTime(GarbageCollectionWait):
$GarbageCollectionTimer.wait_time = GarbageCollectionWait
func _Garbage_Collect():
print("Garbage Collection: Started" )
for i in get_children():
if i:
if i.name.begins_with("@"):
if i.playing != true:
i.queue_free()
print("Garbage Collection: Cleared Sound")
4 changes: 4 additions & 0 deletions AutoLoads/SoundController.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
[node name="Node" type="Node"]
pause_mode = 2
script = ExtResource( 1 )

[node name="GarbageCollectionTimer" type="Timer" parent="."]
wait_time = 5.0
autostart = true
10 changes: 5 additions & 5 deletions Scenes/Menus/Splash.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0.5, 2.01 ),
"times": PoolRealArray( 0.43, 2.01 ),
"transitions": PoolRealArray( 1, 1 ),
"values": [ {
"args": [ ],
Expand Down Expand Up @@ -255,21 +255,21 @@ anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -47.5001
margin_left = -512.0
margin_top = -14.5
margin_right = 47.5001
margin_right = -416.999
margin_bottom = 14.5
custom_fonts/font = SubResource( 4 )
custom_colors/font_color = Color( 1, 1, 1, 1 )
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
text = "linux"
custom_fonts/font = SubResource( 4 )
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}

[node name="ProgressBar" type="ProgressBar" parent="."]
modulate = Color( 1, 1, 1, 0 )
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
Expand Down
3 changes: 2 additions & 1 deletion Scripts/Menus/Splash.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ func start_load():
var rand = RandomNumberGenerator.new()
rand.randomize()
var waittime = rand.randf_range(0.005, 0.020)
print(waittime)
Resources.loadResources()
while $ProgressBar.value != 100:
$ProgressBar.value += 5
# loading stuff for future
yield(get_tree().create_timer(waittime), "timeout")
print("done")
$Splash/Event_Anim.play("loadend")
func _ready():
Resources.loadResources()
if OS.window_fullscreen == true:
OS.window_fullscreen = false
2 changes: 1 addition & 1 deletion Scripts/Menus/TitleScreen.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var prevent = false
var rotateamount = 7
func _ready():
if MusicController.playing == false:
var freaky = load("res://Assets/Menus/Music&Sounds/freakyMenu.ogg")
var freaky = Resources.FreakyMenu
MusicController.play_song(freaky, 102)
func _process(_delta):
if MusicController.playing == true:
Expand Down
Loading

0 comments on commit 0bc8d1f

Please sign in to comment.