Teach some music theory to the computer.
@@ -5,14 +5,13 @@ const PITCH_MIN = 0.8
const PITCH_MAX = 2.6
-func _on_repeater_timeout():
- trigger()
-
func trigger():
- set_pitch_scale(randf_range(PITCH_MIN, PITCH_MAX))
play(0.0)
func _on_trigger_area_entered(area):
trigger()
+
+func _on_star_note_changed(new_note):
+ set_pitch_scale(Music.scale(new_note))
@@ -1,10 +1,17 @@
extends PathFollow2D
# a moving music player
+signal note_changed(new_note: Music.Note)
const SPEED = 200
const RAYON = 20
+@export var note: Music.Note = Music.Note.A
+func _ready():
+ emit_signal("note_changed", note)
func _physics_process(delta):
progress += SPEED * delta
@@ -18,4 +18,5 @@ script = ExtResource("3_dccmh")
[node name="Circle" type="CollisionShape2D" parent="Trigger"]
shape = SubResource("CircleShape2D_6ypex")
+[connection signal="note_changed" from="." to="Sound" method="_on_star_note_changed"]
[connection signal="area_entered" from="Trigger" to="Sound" method="_on_trigger_area_entered"]
@@ -8,6 +8,16 @@
config_version=5
+_global_script_classes=[{
+"base": "RefCounted",
+"class": &"Music",
+"language": &"GDScript",
+"path": "res://utility/Music.gd"
+}]
+_global_script_class_icons={
+"Music": ""
+}
[application]
config/name="StarKiss"
@@ -0,0 +1,12 @@
+class_name Music
+# To deal with music theory in the digital world
+enum Note {A = 1, Ad, B, C, Cd, D, Dd, E, F, Fd, G, Gd}
+const NOTE_PITCH_SCALE = 1.05942
+static func scale(note: Note) -> float:
+ return note * NOTE_PITCH_SCALE
@@ -32,6 +32,7 @@ rotates = false
position = Vector2(167.134, 729.784)
progress = 4210.26
rotates = false
+note = 3
[node name="NiceLine" parent="Lines" instance=ExtResource("3_l2vrj")]
modulate = Color(1, 0, 0, 1)
@@ -40,11 +41,13 @@ curve = SubResource("Curve2D_yypd3")
[node name="ElioStar" parent="Lines/NiceLine" instance=ExtResource("1_wa4bn")]
position = Vector2(1856, 320)
+note = 4
[node name="MiniStar" parent="Lines/NiceLine" instance=ExtResource("1_wa4bn")]
position = Vector2(1354.87, 64)
+note = 6
[node name="Triggers" type="Node2D" parent="."]