online multiplayer chess game (note server currently down)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
extends ColorRect

export(PoolColorArray) var colors
export(float) var length := 2.8

var rainbow := true
onready var fallback_color = color


static func rand(clr) -> float:
	return clamp(clr + rand_range(0, .1) if randi() % 2 else clr - rand_range(0, .1), 0, 1)


func _ready() -> void:
	randomize()
	color = colors[randi() % colors.size()]
	change_color()


func create_timer():
	get_tree().create_timer(length).connect("timeout", self, "change_color")


func change_color() -> void:
	create_timer()
	var tween = create_tween().set_trans(Tween.TRANS_ELASTIC)
	if rainbow:
		var chosen: Color = colors[randi() % colors.size()]
		var clr = Color(rand(chosen.r), rand(chosen.g), rand(chosen.b), 1)
		tween.tween_property(self, "color", clr, length)
	else:
		tween.tween_property(self, "color", fallback_color, length)