bugged-racing/scenes/menu/start_menu.gd

33 lines
1.1 KiB
GDScript
Raw Normal View History

2021-11-12 23:03:35 +00:00
extends Panel
const buggy = preload("res://vehicles/buggy.tscn")
const beetle = preload("res://vehicles/beetlecar.tscn")
2021-11-16 17:48:41 +00:00
const bugmobile = preload("res://vehicles/bugmobile.tscn")
2021-11-12 23:03:35 +00:00
const test_scene = preload("res://scenes/test_level.tscn")
2021-11-13 22:55:18 +00:00
const gui_scene = preload("res://player/gui.tscn")
2021-11-12 23:03:35 +00:00
2021-11-14 21:54:55 +00:00
func _ready() -> void:
2021-11-16 17:48:41 +00:00
$MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/BeetleButton.grab_focus()
2021-11-14 21:54:55 +00:00
2021-11-12 23:03:35 +00:00
func _on_BuggyButton_pressed() -> void:
_start_with_vehicle(buggy.instance())
func _on_BeetleButton_pressed() -> void:
_start_with_vehicle(beetle.instance())
2021-11-16 17:48:41 +00:00
func _on_BugmobileButton_pressed() -> void:
_start_with_vehicle(bugmobile.instance())
2021-11-12 23:03:35 +00:00
func _start_with_vehicle(vehicle: Node) -> void:
2021-11-13 22:55:18 +00:00
var gui = gui_scene.instance()
2021-11-12 23:03:35 +00:00
var scene = test_scene.instance()
2021-11-13 22:55:18 +00:00
vehicle.connect("speed_updated", gui, "update_speed")
vehicle.connect("rpm_updated", gui, "update_rpm")
vehicle.connect("gear_updated", gui, "update_gear")
scene.call_deferred("spawn_player", vehicle, gui)
2021-11-12 23:03:35 +00:00
get_tree().root.call_deferred("add_child", scene)
queue_free()
func _on_BackButton_pressed() -> void:
get_tree().change_scene("res://scenes/menu/main_menu.tscn")