fix gray car colors on second game

This commit is contained in:
interfisch 2025-04-09 08:16:57 +02:00
parent 55ff74065d
commit 35adc2315d
3 changed files with 12 additions and 8 deletions

View file

@ -96,11 +96,11 @@ func setColorwheelstepByPlayernum(playernum:int):
colorwheelstep=0.3
func addPlayer(key:int,poverridecolor=null):
func addPlayer(key:int,poverridecolor:Color=Color(0,0,0,0)):
#return -1 if player already exists with this key. else return id of player added
if not getPlayerkeys().has(key): #key is not yet registered
var prefered_colori=0
var overridecolor=null
var overridecolor:Color=Color(0,0,0,0)
var setrank=((randf()-0.5)/10.0)+0.5
for p in last_players:
if p.inputkey==key: #key was used in last round
@ -114,10 +114,10 @@ func addPlayer(key:int,poverridecolor=null):
prefered_colori+=1
var newplayer: Player = Player.new(key,prefered_colori)
if overridecolor!=null:
if overridecolor.a>0:
newplayer.setOverrideColor(overridecolor)
newplayer.rank=setrank
if poverridecolor!=null:
if poverridecolor.a>0:
print("play key "+str(key)+" overridecolor="+str(poverridecolor))
newplayer.setOverrideColor(poverridecolor)
players.append(newplayer)

View file

@ -16,8 +16,9 @@ func _ready() -> void:
if len(Gamestate.getSelectedMap())<=0: #no map selected (ie on startup)
get_children()[0].emit_signal("pressed") #preselect first map in list
else:
Gamestate.automatic_map_change_in-=1
if Gamestate.automatic_map_change_in<=0: #do automatic mapchange
if Gamestate.automatic_map_change_after>0:
Gamestate.automatic_map_change_in-=1
if Gamestate.automatic_map_change_after>0 and Gamestate.automatic_map_change_in<=0: #do automatic mapchange
Gamestate.automatic_map_change_in=Gamestate.automatic_map_change_after #reset
var next_map_pick=null
while next_map_pick==null:
@ -28,7 +29,7 @@ func _ready() -> void:
var saved_automatic_map_change_in=Gamestate.automatic_map_change_in #save number, to restore after simulated map button press
next_map_pick.emit_signal("pressed")
Gamestate.automatic_map_change_in=saved_automatic_map_change_in
else: #no automatic mapchange mapchange
else: #no automatic mapchange
for c in get_children():
if c.name==button_prefix+Gamestate.getSelectedMap():
var saved_automatic_map_change_in=Gamestate.automatic_map_change_in #save number, to restore after simulated map button press

View file

@ -61,5 +61,8 @@ func _process(delta: float) -> void:
label.add_theme_constant_override("outline_size",outlinesize)
$MapChangeInfo.text="Mapchange in "+str(Gamestate.automatic_map_change_in)
if Gamestate.automatic_map_change_in>0:
$MapChangeInfo.text="Mapchange in "+str(Gamestate.automatic_map_change_in)
else:
$MapChangeInfo.text=""