menu and level select ready

This commit is contained in:
Clevertop 2024-08-13 01:24:47 +10:00
parent 311c0395ab
commit f470efbe1f
10 changed files with 61 additions and 11 deletions

View file

@ -170,3 +170,8 @@ func open_termimal():
func _on_player_object_clicked(object):
if(object.name == "StartButton"):
start_room()
func _on_area_3d_body_entered(body):
if body.name == "Player":
GameManager.load_next_level()

5
Scripts/level_res.gd Normal file
View file

@ -0,0 +1,5 @@
extends Resource
class_name LevelRes
@export var level_path : String
@export var level_name : String

View file

@ -5,9 +5,16 @@ var credits_shown : bool = false
@export var level_node : Control
@export var credits_node : Control
@export var credits_button : Button
@export var levels_vbox : VBoxContainer
# Called when the node enters the scene tree for the first time.
func _ready():
for level_num in GameManager.levels.size():
var new_button : Button = Button.new()
new_button.text = "Level " + str(level_num) + " : " + GameManager.levels[level_num].level_name
new_button.pressed.connect(func(): pick_level(GameManager.levels[level_num].level_name))
levels_vbox.add_child(new_button)
pass # Replace with function body.
@ -23,6 +30,11 @@ func _process(delta):
credits_button.text = "Credits"
func pick_level(picked_level:String):
for level in GameManager.levels:
if level.level_name == picked_level:
get_tree().change_scene_to_file(level.level_path)
func _on_credits_button_pressed():
credits_shown = !credits_shown