-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings.gd
69 lines (59 loc) · 1.56 KB
/
settings.gd
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
extends Node
var score_file = "user://highscore.save"
var settings_file = "user://settings.save"
var enable_sound = true
var enable_music = true
var circles_per_level = 1
var color_schemes = {
"NEON1": {
'background': Color8(0, 0, 0),
'player_body': Color8(203, 255, 0),
'player_trail': Color8(204, 0, 255),
'circle_fill': Color8(255, 0, 110),
'circle_static': Color8(0, 255, 102),
'circle_limited': Color8(204, 0, 255)
},
"NEON2": {
'background': Color8(0, 0, 0),
'player_body': Color8(246, 255, 0),
'player_trail': Color8(255, 255, 255),
'circle_fill': Color8(255, 0, 110),
'circle_static': Color8(151, 255, 48),
'circle_limited': Color8(127, 0, 255)
},
"NEON3": {
'background': Color8(0, 0, 0),
'player_body': Color8(255, 0, 187),
'player_trail': Color8(255, 148, 0),
'circle_fill': Color8(255, 148, 0),
'circle_static': Color8(170, 255, 0),
'circle_limited': Color8(204, 0, 255)
}
}
var theme = color_schemes["NEON3"]
func changeTheme(_theme):
theme = _theme
static func rand_weighted(weights):
var sum = 0
for weight in weights:
sum += weight
var num = rand_range(0, sum)
for i in weights.size():
if num < weights[i]:
return i
num -= weights[i]
func save_settings():
var f = File.new()
f.open(settings_file, File.WRITE)
f.store_var(enable_sound)
f.store_var(enable_music)
# f.store_var(enable_ads)
f.close()
func load_settings():
var f = File.new()
if f.file_exists(settings_file):
f.open(settings_file, File.READ)
enable_sound = f.get_var()
enable_music = f.get_var()
# self.enable_ads = f.get_var()
f.close()