diff --git a/scripts/car_node.gd b/scripts/car_node.gd index be6852d..8e2018d 100644 --- a/scripts/car_node.gd +++ b/scripts/car_node.gd @@ -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() diff --git a/scripts/game.gd b/scripts/game.gd index 282ba7d..1f7054c 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -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: diff --git a/scripts/label_round.gd b/scripts/label_round.gd index 9193c93..2f7b2b9 100644 --- a/scripts/label_round.gd +++ b/scripts/label_round.gd @@ -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)