- Introduced explicit typing to variables and functions across multiple scripts for better code clarity. - Specified 'void' as the return type for functions that do not return a value. - Removed redundant code in some scripts.
47 lines
1.1 KiB
GDScript
47 lines
1.1 KiB
GDScript
extends Level
|
|
class_name MainMenu
|
|
|
|
@onready var level_select : MenuButton = get_node("%MenuButton")
|
|
@onready var high_scores : Button = get_node("%HighScores")
|
|
@onready var exit_button : Button = get_node("%ExitGame")
|
|
|
|
func _ready() -> void:
|
|
level_select.get_popup().id_pressed.connect(_on_item_menu_pressed)
|
|
high_scores.connect("pressed", Callable(self, "on_high_scores_pressed"))
|
|
exit_button.connect("pressed", Callable(self, "on_exit_pressed"))
|
|
update_game_state()
|
|
|
|
|
|
func _on_item_menu_pressed(id : int) -> void:
|
|
## Load the appropriate level based on the selection that has been made
|
|
Log.pr(id)
|
|
|
|
match id:
|
|
1:
|
|
# Load level 1
|
|
SceneMgr.load_scene("LEVEL1")
|
|
2:
|
|
# Load level 2
|
|
SceneMgr.load_scene("LEVEL2")
|
|
3:
|
|
# Load level 3
|
|
SceneMgr.load_scene("LEVEL3")
|
|
4:
|
|
# Load level 4
|
|
SceneMgr.load_scene("LEVEL4")
|
|
5:
|
|
# Load level 5
|
|
SceneMgr.load_scene("LEVEL5")
|
|
6:
|
|
# Load level 6
|
|
SceneMgr.load_scene("LEVEL6")
|
|
|
|
func on_high_scores_pressed() -> void:
|
|
## Load the high scores screen
|
|
Log.pr("High scores button pressed")
|
|
SceneMgr.load_scene("HIGHSCORES")
|
|
pass
|
|
|
|
func on_exit_pressed() -> void:
|
|
# Quit the game
|
|
get_tree().quit()
|