From c1992fcfc180aa29953bf789258fc6b8459cfd87 Mon Sep 17 00:00:00 2001 From: Fisch Date: Sat, 9 Nov 2024 12:44:44 +0100 Subject: [PATCH] keep playercolors for next round --- scripts/game.gd | 4 +++- scripts/gamestate.gd | 42 +++++++++++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/scripts/game.gd b/scripts/game.gd index 432b3f5..e906827 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -134,9 +134,11 @@ func _process(delta: float) -> void: if game_ended: var anyplayerkeypressed=false + var id=0 for p in Gamestate.getPlayers(): - if Input.is_action_pressed(Gamestate.userinput_prefix+str(p.id)): + if Input.is_action_pressed(Gamestate.userinput_prefix+str(id)): anyplayerkeypressed=true + id+=1 if anyplayerkeypressed and timer_close.time_left Array[Player]: class Player: var inputkey:int var color:Color - var id:int + var colori - func _init(key:int, i:int=-1): + func _init(key:int, pcolori:int=-1): inputkey=key - id=i + colori=pcolori var sat = 1.0 var val = 0.7 - if i<0: + if colori<0: color=Color.from_hsv(randf_range(0.0,1.0), sat,val,1.0) else: - color=Color.from_hsv(fmod(0.3*i,1.0), sat,val,1.0) - print("i is "+str(i)+" h="+str(fmod(0.3*i,1.0))+" assigned color "+str(color)) + color=Color.from_hsv(fmod(0.3*colori,1.0), sat,val,1.0) + print("i is "+str(colori)+" h="+str(fmod(0.3*colori,1.0))+" assigned color "+str(color)) func startGame():