fix round display when custom map rounds

This commit is contained in:
interfisch 2025-03-24 20:35:20 +01:00
parent 37e0c0470d
commit 0fad385344
3 changed files with 7 additions and 1 deletions

View file

@ -4,6 +4,9 @@ extends Node2D
var reference_gamestateplayer
func setMapRounds(r:int):
$CharacterBody_Car/label_round.map_rounds=r
func getSpeed() -> float:
return cbcar.velocity.length()

View file

@ -62,6 +62,7 @@ func _ready() -> void:
if (mapsceneinstance.override_rounds_number>0): #if set to 0, do not override
map_rounds=mapsceneinstance.override_rounds_number
print(str(checkpoints.size())+" Checkpoints found")
@ -84,6 +85,7 @@ func _ready() -> void:
newcarinstance.setCheckpoints(checkpoints,map_rounds)
newcarinstance.getCharacterBody().car_finished.connect(_on_car_finished)
newcarinstance.getCharacterBody().car_on_checkpoint.connect(_on_car_on_checkpoint)
newcarinstance.setMapRounds(map_rounds) #give information to each car (to show correct rounds number)
var startmarker:Sprite2D=mapsceneinstance.get_node("startmarker")
if startmarker != null:

View file

@ -2,6 +2,7 @@ extends Label
@onready var animation_player: AnimationPlayer = $"../AnimationPlayer"
var map_rounds=0
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@ -13,7 +14,7 @@ func _process(delta: float) -> void:
pass
func showRounds(round):
var rounds=Gamestate.getRounds()
var rounds=map_rounds
if (round==-1): #finished
round=rounds
text=str(round)+"/"+str(rounds)