2021-11-12 23:03:35 +00:00
|
|
|
extends Panel
|
|
|
|
|
|
|
|
const buggy = preload("res://vehicles/buggy.tscn")
|
|
|
|
const beetle = preload("res://vehicles/beetlecar.tscn")
|
|
|
|
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
|
|
|
|
|
|
|
func _on_BuggyButton_pressed() -> void:
|
|
|
|
_start_with_vehicle(buggy.instance())
|
|
|
|
|
|
|
|
func _on_BeetleButton_pressed() -> void:
|
|
|
|
_start_with_vehicle(beetle.instance())
|
|
|
|
|
|
|
|
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")
|