set colorwheelsteps based on whitelist size

This commit is contained in:
interfisch 2024-12-29 19:52:44 +01:00
parent 09043f2794
commit 7e3cfdf5db
3 changed files with 68 additions and 2 deletions

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=12 format=3 uid="uid://b1uhymisifcho"]
[gd_scene load_steps=15 format=3 uid="uid://b1uhymisifcho"]
[ext_resource type="Script" path="res://scripts/menu.gd" id="1_fushn"]
[ext_resource type="Script" path="res://scripts/menudisplay.gd" id="2_jc4pv"]
@ -12,6 +12,44 @@
[ext_resource type="Texture2D" uid="uid://bst8p5s1sgurm" path="res://sprites/menu_bg.png" id="10_equk1"]
[ext_resource type="Texture2D" uid="uid://drgqjl330tj2p" path="res://scenes/map_preview/no_preview.png" id="11_3sx36"]
[sub_resource type="Animation" id="Animation_y58ke"]
resource_name = "menu_idle"
length = 60.0
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("MenuBg:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 60),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [0.0, 6.28319]
}
[sub_resource type="Animation" id="Animation_7lydi"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("MenuBg:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [0.0]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_08km3"]
_data = {
"RESET": SubResource("Animation_7lydi"),
"menu_idle": SubResource("Animation_y58ke")
}
[node name="Menu" type="Node"]
script = ExtResource("1_fushn")
@ -173,6 +211,12 @@ offset_bottom = 26.0
theme_override_constants/outline_size = 10
text = "Rounds:"
[node name="AnimationPlayer" type="AnimationPlayer" parent="MenuDisplay"]
libraries = {
"": SubResource("AnimationLibrary_08km3")
}
autoplay = "menu_idle"
[node name="Timer" type="Timer" parent="."]
wait_time = 5.0

View file

@ -15,6 +15,8 @@ var map_scene_name_postfix=".tscn"
var rounds=3
var colorwheelstep:float=0.3
func getRounds():
return rounds
@ -38,6 +40,25 @@ func checkColoriFree(i):
free=false
return free
func setColorwheelstepByPlayernum(playernum:int):
if playernum==2:
colorwheelstep=0.5
elif playernum==3:
colorwheelstep=0.33
elif playernum==4:
colorwheelstep=0.25
elif playernum==5:
colorwheelstep=0.4
elif playernum==6:
colorwheelstep=0.16
elif playernum==7:
colorwheelstep=1.0/7*4
elif playernum==8:
colorwheelstep=1.0/8*3
else:
colorwheelstep=0.3
func addPlayer(key:int):
#return -1 if player already exists with this key. else return id of player added
@ -92,7 +113,7 @@ class Player:
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*colori,1.0), sat,val,1.0) #todo: make colorwheel smaller when whitelist enabled
color=Color.from_hsv(fmod(Gamestate.colorwheelstep*colori,1.0), sat,val,1.0)
func startGame():

View file

@ -18,6 +18,7 @@ func _ready():
btn_save_whitelist.disabled=keywhitelist.size()>0 #whitelist enabled, then disable save whitelist button
btn_save_whitelist.visible=!keywhitelist.size()>0
print("Loaded Keywhitelist="+str(keywhitelist))
Gamestate.setColorwheelstepByPlayernum(keywhitelist.size())
#Preload players to set colors
if keywhitelist.size()>0: #add whitelisted players if whitelist enabled and remove them afterwards