-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSpawner.gd
114 lines (95 loc) · 2.64 KB
/
Spawner.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
extends Node2D
export (PackedScene) var instruction_type
export (float) var MX_BPM
export (int) var Time
export (int) var Measure
export (float) var barTime
export(Array, int, FLAGS, "1,2,3,4,5,6") var notes setget notes_set, notes_get
export(Array, int, FLAGS, "1,2,3,4,5,6") var Level1
export(Array, int, FLAGS, "1,2,3,4,5,6") var Level2
export(Array, int, FLAGS, "1,2,3,4,5,6") var Level3
var eval_array
var dbg
var detector
var notes_array
var currentLevel = 0
var existingNote
func _ready():
notes = Level1
# Called when the node is added to the scene for the first time.
barTime = ((60 * 1) / MX_BPM) / 2
eval_array = []
detector = $"../Detector"
dbg = $"../../Debug"
notes_array = [false, false, false, false, false, false]
func _process(delta):
pass
func change_level():
currentLevel += 1
#var level_array = "Level"+String(currentLevel)
if currentLevel == 1:
notes = Level2
if currentLevel == 2:
notes = Level3
func setup_notes_array():
# Clear the notes
notes_array = [false, false, false, false, false, false]
var random_pattern = randi() % notes.size()
var fixed_pattern = 2
# Check if there's a note for the current beat
# Casiila: 1 2 3 4 5 6
# Valor: 1 2 4 8 16 32
match notes[random_pattern]:
1:
# Create a whole note
notes_array[0] = true
9:
# Create a a white note, then a whole note
notes_array[0] = true
notes_array[3] = true
17:
# Create a whole note, then a white note
notes_array[0] = true
notes_array[4] = true
21:
# Create 3 white notes
notes_array[0] = true
notes_array[2] = true
notes_array[4] = true
42:
notes_array[1] = true
notes_array[3] = true
notes_array[5] = true
63:
# Create 6 negras
notes_array[0] = true
notes_array[1] = true
notes_array[2] = true
notes_array[3] = true
notes_array[4] = true
notes_array[5] = true
func create_note(index):
if notes_array[index - 1]:
create_instruction()
func create_instruction():
var instruction_i = instruction_type.instance()
instruction_i.position.x = self.position.x
instruction_i.position.y = self.position.y
# Get a random letter for the instantiated Instruction
var random_index = randi() % $"../".keys.size()
var letter = $"../".get_letter(random_index)
# var random_index = randi() % instruction_i.TYPES.size()
# var letter = instruction_i.TYPES[random_index]
instruction_i.initialize({
"target": $Target,
"letter": letter,
"tween_duration": barTime
})
eval_array.append(instruction_i)
get_parent().add_child(instruction_i)
instruction_i.appear()
detector.nextInstruction = instruction_i
func notes_set(new_value):
notes = new_value
func notes_get():
return notes