quality update and sound

This commit is contained in:
2024-01-26 18:28:18 +01:00
parent 6c30e59eaa
commit e31fd502ae
30 changed files with 232 additions and 14 deletions

View File

@@ -1,5 +1,7 @@
extends Node
signal level_switched
@onready var transition: CanvasLayer = $Transition
@export var levels: Array[PackedScene]
@@ -12,17 +14,19 @@ func _ready() -> void:
progress_save.load(PROGRESS_SAVE_PATH)
func next_level() -> void:
level_pointer += 1
if level_pointer < levels.size():
transition.show()
get_tree().paused = true
await get_tree().create_timer(1).timeout
get_tree().change_scene_to_packed(levels[level_pointer])
await get_tree().create_timer(2).timeout
level_switched.emit()
get_tree().paused = false
transition.hide()
else:
get_tree().change_scene_to_file("res://scenes/gui/menus/game_finished.tscn")
level_switched.emit()
level_pointer += 1
func start_last_level() -> void:
pass

View File

@@ -0,0 +1,15 @@
extends Node
@onready var soundeffect: SoundEffect = $SoundEffect
func _ready() -> void:
_on_level_switched()
LevelManager.level_switched.connect(_on_level_switched)
func _on_level_switched() -> void:
print(get_tree().current_scene.name)
match get_tree().current_scene.name:
"MainMenu":
soundeffect.play_key("main")
"LVL1":
soundeffect.play_key("lvl1")

View File

@@ -42,7 +42,7 @@ func uncapture_mouse() -> void:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
func _input(event: InputEvent) -> void:
if event.is_action_pressed("pause"):
if event.is_action_pressed("pause") && !get_tree().current_scene is MainMenu:
show_pause_menu()
func toggle_fullscreen() -> void:

View File

@@ -1,7 +1,12 @@
extends Node3D
@onready var anim: AnimationPlayer = $AnimationPlayer
@onready var audio: AudioStreamPlayer3D = $AudioStreamPlayer3D
func open(): anim.play("open")
func open():
anim.play("open")
audio.play()
func close(): anim.play_backwards("open")
func close():
anim.play_backwards("open")
audio.play()

View File

@@ -1,12 +1,15 @@
extends Completer
@onready var animation_player: AnimationPlayer = $AnimationPlayer
@onready var soundeffect_3d: SoundEffect3D = $SoundEffect3D
func _on_interaction_area_interacted():
if completed:
animation_player.play_backwards("press")
soundeffect_3d.play_key("down")
else:
animation_player.play("press")
soundeffect_3d.play_key("up")
toggle_complete()
if one_shot:
await animation_player.animation_finished

View File

@@ -7,8 +7,7 @@ func _ready() -> void:
LevelManager.level_pointer = 0
func _on_start_game_pressed() -> void:
get_tree().change_scene_to_file("res://scenes/levels/lvl_1.tscn")
LevelManager.next_level()
func _on_quit_game_pressed() -> void:
get_tree().quit()

View File

@@ -1,5 +1,5 @@
extends AudioStreamPlayer
class_name SoundEffect
class_name SoundEffect
@export var audio_library: Array[SoundeffectResource]
@export_range(0,2) var pitch_variation: float

View File

@@ -0,0 +1,14 @@
extends AudioStreamPlayer3D
class_name SoundEffect3D
@export var audio_library: Array[SoundeffectResource]
@export_range(0,2) var pitch_variation: float
func play_key(key: String) -> void:
for res in audio_library:
if res.key == key:
stream = res.audio
pitch_scale = 1 + randf_range(pitch_variation * -1, pitch_variation)
play()
return
push_error(key + " is not available in the Audio Library variable")