add train control game
This commit is contained in:
24
scripts/traincontrol.gd
Normal file
24
scripts/traincontrol.gd
Normal file
@@ -0,0 +1,24 @@
|
||||
extends Node3D
|
||||
@export var main_scene: PackedScene
|
||||
|
||||
@onready var speed_label : Label = $HUD/speed_label
|
||||
@onready var camera_label : Label = $HUD/camera_label
|
||||
@onready var train: MeshInstance3D = $Ground/Rails/TrainEngine/Train
|
||||
@onready var camera: TrainControlCamera = $TrainCamera
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
_update_ui()
|
||||
|
||||
if Input.is_action_just_pressed("ui_cancel"):
|
||||
SceneSwitcher.switch_scene(main_scene.resource_path)
|
||||
|
||||
|
||||
|
||||
func _update_ui() -> void:
|
||||
if speed_label and train:
|
||||
var kmh = train.get_speed() * 3.6
|
||||
speed_label.text = "Velocità: %.0f km/h" % kmh
|
||||
|
||||
if camera_label and camera:
|
||||
camera_label.text = "Camera: %s" % camera.get_mode_name()
|
||||
Reference in New Issue
Block a user