Second Map, and sound effects
This commit is contained in:
@ -31,6 +31,9 @@ var coins = 0
|
||||
var save_path = "user://map_scores.save"
|
||||
var map_scores = {}
|
||||
|
||||
var SFX_loudness = 1.0
|
||||
var master_volume = 1.0
|
||||
var music_volume_raw = 1.0
|
||||
|
||||
func _ready() -> void:
|
||||
get_node("pausemenu").hide()
|
||||
@ -68,6 +71,19 @@ func _ready() -> void:
|
||||
if file:
|
||||
map_scores = file.get_var()
|
||||
file.close()
|
||||
|
||||
var config = ConfigFile.new()
|
||||
var err = config.load("user://settings.cfg")
|
||||
if err == OK:
|
||||
var master_volume_raw = config.get_value("audio", "master_volume", 100.0)
|
||||
master_volume = clamp(master_volume_raw / 100.0, 0.0, 1.0)
|
||||
var sfx_volume_raw = config.get_value("audio", "sfx_volume", 100.0)
|
||||
SFX_loudness = clamp(sfx_volume_raw / 100.0, 0.0, 1.0)
|
||||
var music_volume_raw = config.get_value("audio", "music_volume", 100.0)
|
||||
SFX_loudness = clamp(sfx_volume_raw / 100.0, 0.0, 1.0)
|
||||
self.get_node("HealthLostAudio").volume_db = linear_to_db(master_volume * SFX_loudness)
|
||||
self.get_node("GameOverAudio").volume_db = linear_to_db(master_volume * music_volume_raw)
|
||||
self.get_node("VictoryAudio").volume_db = linear_to_db(master_volume * music_volume_raw)
|
||||
|
||||
func _process(delta : float)-> void:
|
||||
coinlabel.text = "Coins: " + str(coins)
|
||||
@ -84,6 +100,8 @@ func get_Lifes():
|
||||
|
||||
func Update_Lifes(amount) -> void:
|
||||
lives += amount
|
||||
if amount < 0:
|
||||
get_node("HealthLostAudio").play()
|
||||
|
||||
func Update_waves(wavecount) -> void:
|
||||
get_node("WaveCounter/HBoxContainer/Label").text = "Current wave: "+ str(wavecount)
|
||||
@ -169,6 +187,8 @@ func GameOver() -> void:
|
||||
var timer_node = i.get_node("Timer") if i.has_node("Timer") else null
|
||||
if timer_node:
|
||||
timer_node.stop()
|
||||
get_parent().get_parent().get_node("MusicPlayer").PauseAudio()
|
||||
get_node("GameOverAudio").play()
|
||||
|
||||
func GameWon() -> void:
|
||||
get_node("Panel").hide()
|
||||
@ -179,6 +199,8 @@ func GameWon() -> void:
|
||||
if file:
|
||||
file.store_var(map_scores)
|
||||
file.close()
|
||||
get_parent().get_parent().get_node("MusicPlayer").PauseAudio()
|
||||
get_node("VictoryAudio").play()
|
||||
|
||||
func _on_button_3_pressed() -> void:
|
||||
get_node("pausemenu").hide()
|
||||
|
Reference in New Issue
Block a user