White space/formatting clean up and better audio defaults.
This commit is contained in:
+10
-10
@@ -8,7 +8,7 @@ Fade_State :: enum {
|
||||
Out,
|
||||
}
|
||||
|
||||
// setup sound IDs so gameplay code never
|
||||
// setup sound IDs so gameplay code never
|
||||
// touches raw Raylib sound handles
|
||||
Sound_ID :: enum {
|
||||
Ball_Collision,
|
||||
@@ -20,12 +20,12 @@ Sound_ID :: enum {
|
||||
Audio_Manager :: struct {
|
||||
sounds: map[Sound_ID]rl.Sound,
|
||||
music: rl.Music,
|
||||
music_loaded: bool,
|
||||
|
||||
music_loaded: bool, //
|
||||
|
||||
sfx_vol: f32, // User SFX volume setting
|
||||
user_music_vol: f32, // User Music volume setting
|
||||
current_music_vol: f32, // Live interpolated output volume
|
||||
|
||||
|
||||
// Runtime Fade State
|
||||
fade_state: Fade_State,
|
||||
fade_elapsed_sec: f32,
|
||||
@@ -40,13 +40,13 @@ audio_init :: proc(audio: ^Audio_Manager) {
|
||||
audio.sounds = make(map[Sound_ID]rl.Sound)
|
||||
|
||||
// Load SFX
|
||||
audio.sfx_vol = 0.3
|
||||
audio.sfx_vol = 0.4
|
||||
audio.sounds[.UI_Select] = rl.LoadSound("assets/audio/ui/select.ogg")
|
||||
audio.sounds[.Ball_Collision] = rl.LoadSound("assets/audio/gameplay/ballhit.ogg")
|
||||
|
||||
// Load Music Stream
|
||||
audio.user_music_vol = 0.1
|
||||
audio.current_music_vol = 0.1
|
||||
audio.user_music_vol = 0.4
|
||||
audio.current_music_vol = 0.4
|
||||
audio.fade_state = .None
|
||||
audio.music = rl.LoadMusicStream("assets/audio/gameplay/music/track_1.wav")
|
||||
audio.music_loaded = true
|
||||
@@ -91,7 +91,7 @@ audio_update :: proc(audio: ^Audio_Manager, dt: f32) {
|
||||
|
||||
audio_manager_quit :: proc(audio: ^Audio_Manager) {
|
||||
for _, sound in audio.sounds {
|
||||
rl.UnloadSound(sound)
|
||||
rl.UnloadSound(sound)
|
||||
}
|
||||
delete(audio.sounds)
|
||||
rl.UnloadMusicStream(audio.music)
|
||||
@@ -119,7 +119,7 @@ audio_stop_music :: proc(audio: ^Audio_Manager) {
|
||||
audio_play_sfx :: proc(audio: ^Audio_Manager, id: Sound_ID) {
|
||||
if sound, ok := audio.sounds[id]; ok {
|
||||
rl.SetSoundVolume(sound, audio.sfx_vol)
|
||||
rl.PlaySound(sound)
|
||||
rl.PlaySound(sound)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,4 +146,4 @@ audio_fade_out :: proc(audio: ^Audio_Manager, duration: f32 = 1.0) {
|
||||
audio.fade_state = .Out
|
||||
audio.fade_duration_sec = max(0.001, duration)
|
||||
audio.fade_elapsed_sec = 0.0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,4 +93,4 @@ poll_input :: proc() -> Input_Event {
|
||||
(gamepad_active && rl.IsGamepadButtonPressed(gid, .MIDDLE_RIGHT))
|
||||
|
||||
return input_event
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user