Leo -Assets für GUI geladen

This commit is contained in:
2022-12-11 01:15:21 +01:00
parent 5e6b25f5cc
commit 553214600e
11 changed files with 241 additions and 0 deletions

30
menu/Speedometer.gd Normal file
View File

@@ -0,0 +1,30 @@
extends CanvasLayer
var currentSpeed
var maxSpeed = float(TrainEngine.maxSpeed)
var minSpeed = 0.0
var deg
var rad
@onready var root = self.get_parent()
func _ready():
#get Game Node reference
while not root is Game:
root = root.get_parent()
print(root.name)
print(maxSpeed)
#acceptable rotations range from -35 to +35 degrees
func _process(delta):
currentSpeed = root.p1_train.current_speed
deg = ((70.0/maxSpeed)* currentSpeed) - 35.0
rad = (deg * 3.14)/180.0
self.get_node("Pfeil").rotation = rad
func round_to_digit(num, digit):
return round(num * pow(10.0, digit)) / pow(10.0, digit)