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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
extends Control

const world = preload("res://World.tscn")

export(float) var timer_length := 0.0

export(Array, Color) var nice_colors

onready var settings := $ColorRect/Settings
onready var colorrect := $ColorRect
onready var tween := $Tween
onready var timer := $Timer
onready var lobby := $ColorRect/Lobby


func _ready():
	randomize()
	colorrect.color = nice_colors[randi() % nice_colors.size()]
	timer.start(timer_length)
	_on_Timer_timeout()


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


func _on_local_pressed():
	get_tree().change_scene_to(world)


func _on_quit_pressed():
	get_tree().quit()


func _on_settings_pressed():
	settings.toggle(true)


func _on_Timer_timeout():
	var clr = nice_colors[randi() % nice_colors.size()]
	clr.r = rand(clr.r)
	clr.b = rand(clr.b)
	clr.g = rand(clr.g)
	tween.interpolate_property(colorrect, "color", colorrect.color, clr, timer_length, Tween.TRANS_ELASTIC)
	tween.start()
	timer.start(timer_length)


func _on_multiplayer_pressed():
	lobby.toggle(true)