it's kinda fun now
This commit is contained in:
parent
6cedd51ec1
commit
b55b68bcf2
6
click_track.tscn
Normal file
6
click_track.tscn
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[gd_scene format=3 uid="uid://dduyumwk5v1ge"]
|
||||||
|
|
||||||
|
[ext_resource type="AudioStream" uid="uid://b8n6p428csquv" path="res://assets/audio/full/eine-kleine-click.wav" id="1_048mw"]
|
||||||
|
|
||||||
|
[node name="ClickTrack" type="AudioStreamPlayer2D" unique_id=1931221522]
|
||||||
|
stream = ExtResource("1_048mw")
|
||||||
48
main.gd
Normal file
48
main.gd
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#@tool
|
||||||
|
#@icon(icon_path: String)
|
||||||
|
#class_name MyNode
|
||||||
|
extends Node
|
||||||
|
## Documentation comments
|
||||||
|
|
||||||
|
## signal
|
||||||
|
## enum
|
||||||
|
## const
|
||||||
|
## @export var
|
||||||
|
var musicians: Array[Node]
|
||||||
|
var musician_lights: Array[Node]
|
||||||
|
|
||||||
|
@onready var rhythm_manager: RhythmManager = %RhythmManager
|
||||||
|
@onready var conductor: AnimatedSprite2D = $Conductor
|
||||||
|
@onready var conductor_light: PointLight2D = %ConductorLight
|
||||||
|
@onready var click_track: AudioStreamPlayer2D = %ClickTrack
|
||||||
|
|
||||||
|
## OVERRIDES
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
musicians = get_tree().get_nodes_in_group("musicians")
|
||||||
|
musician_lights = get_tree().get_nodes_in_group("musician_lights")
|
||||||
|
rhythm_manager.connect("song_started", on_song_started)
|
||||||
|
#func _process(delta: float) -> void:
|
||||||
|
#pass
|
||||||
|
#
|
||||||
|
#func _physics_process(delta: float) -> void:
|
||||||
|
#pass
|
||||||
|
|
||||||
|
func _unhandled_input(event: InputEvent) -> void:
|
||||||
|
if event.is_action_pressed("ready"):
|
||||||
|
conductor.play("default")
|
||||||
|
conductor_light.visible = true
|
||||||
|
click_track.play()
|
||||||
|
## CORE
|
||||||
|
|
||||||
|
## PRIVATE/HELPER
|
||||||
|
|
||||||
|
## RECEIVERS
|
||||||
|
|
||||||
|
func on_song_started() -> void:
|
||||||
|
for musician in musicians:
|
||||||
|
musician.play("default")
|
||||||
|
for light in musician_lights:
|
||||||
|
light.visible = true
|
||||||
|
|
||||||
|
## SETTERS/GETTERS
|
||||||
1
main.gd.uid
Normal file
1
main.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://bjv7i1kmivfai
|
||||||
@ -47,6 +47,11 @@ start={
|
|||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
ready={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":114,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
|
|||||||
4
resources/light_occluder_polygon.tres
Normal file
4
resources/light_occluder_polygon.tres
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[gd_resource type="OccluderPolygon2D" format=3 uid="uid://inxtfgsnw5sq"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
polygon = PackedVector2Array(0, 12, 4, 13, 0, 14, -4, 13)
|
||||||
13
resources/point_light_texture.tres
Normal file
13
resources/point_light_texture.tres
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[gd_resource type="GradientTexture2D" format=3 uid="uid://d1li1mlxutaym"]
|
||||||
|
|
||||||
|
[sub_resource type="Gradient" id="Gradient_lquwl"]
|
||||||
|
interpolation_mode = 2
|
||||||
|
offsets = PackedFloat32Array(0.5, 0.8)
|
||||||
|
colors = PackedColorArray(1, 1, 1, 1, 0, 0, 0, 0)
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
gradient = SubResource("Gradient_lquwl")
|
||||||
|
width = 128
|
||||||
|
fill = 1
|
||||||
|
fill_from = Vector2(0.5, 0.5)
|
||||||
|
fill_to = Vector2(0.85, 0.85)
|
||||||
@ -4,10 +4,11 @@ class_name RhythmManager
|
|||||||
extends Node2D
|
extends Node2D
|
||||||
## Documentation comments
|
## Documentation comments
|
||||||
|
|
||||||
## signal
|
signal song_started()
|
||||||
## enum
|
## enum
|
||||||
## const
|
## const
|
||||||
|
|
||||||
|
@export var target_audio: AudioStreamPlayer2D
|
||||||
@export var tempo: int = 120
|
@export var tempo: int = 120
|
||||||
@export var beats_per_measure: int = 4
|
@export var beats_per_measure: int = 4
|
||||||
|
|
||||||
@ -26,15 +27,17 @@ var click_track_stream: AudioStream
|
|||||||
#var delay_time: float
|
#var delay_time: float
|
||||||
|
|
||||||
@onready var beat_bar: ProgressBar = %BeatBar
|
@onready var beat_bar: ProgressBar = %BeatBar
|
||||||
@onready var click_track: AudioStreamPlayer2D = %ClickTrack
|
#@onready var click_track: AudioStreamPlayer2D = %ClickTrack
|
||||||
@onready var beat_time_value: Label = %BeatTimeValue
|
@onready var beat_time_value: Label = %BeatTimeValue
|
||||||
@onready var volume_bar_left: ProgressBar = %VolumeBarLeft
|
@onready var volume_bar_left: ProgressBar = %VolumeBarLeft
|
||||||
@onready var volume_bar_right: ProgressBar = %VolumeBarRight
|
@onready var volume_bar_right: ProgressBar = %VolumeBarRight
|
||||||
|
@onready var volume_value_left: Label = %VolumeValueLeft
|
||||||
|
@onready var volume_value_right: Label = %VolumeValueRight
|
||||||
|
|
||||||
## OVERRIDES
|
## OVERRIDES
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
click_track_stream = click_track.stream
|
#click_track_stream = click_track.stream
|
||||||
ready_time = Time.get_ticks_usec()
|
ready_time = Time.get_ticks_usec()
|
||||||
print("Ready time: %s" % ready_time)
|
print("Ready time: %s" % ready_time)
|
||||||
print("Buses at index 0: %s" % AudioServer.get_bus_name(0))
|
print("Buses at index 0: %s" % AudioServer.get_bus_name(0))
|
||||||
@ -52,6 +55,8 @@ func _process(_delta: float) -> void:
|
|||||||
if is_running:
|
if is_running:
|
||||||
volume_bar_left.value = AudioServer.get_bus_peak_volume_left_db(0, 0)
|
volume_bar_left.value = AudioServer.get_bus_peak_volume_left_db(0, 0)
|
||||||
volume_bar_right.value = AudioServer.get_bus_peak_volume_right_db(0, 0)
|
volume_bar_right.value = AudioServer.get_bus_peak_volume_right_db(0, 0)
|
||||||
|
volume_value_left.text = str(snappedf(AudioServer.get_bus_peak_volume_left_db(0, 0), 0.1))
|
||||||
|
volume_value_right.text = str(snappedf(AudioServer.get_bus_peak_volume_right_db(0, 0), 0.1))
|
||||||
song_time_elapsed = total_time_elapsed - start_time
|
song_time_elapsed = total_time_elapsed - start_time
|
||||||
#print("song time elapsed: %s" % song_time_elapsed)
|
#print("song time elapsed: %s" % song_time_elapsed)
|
||||||
beat_time_elapsed = song_time_elapsed - beat_time_start
|
beat_time_elapsed = song_time_elapsed - beat_time_start
|
||||||
@ -67,17 +72,18 @@ func _process(_delta: float) -> void:
|
|||||||
beat_time_start = song_time_elapsed
|
beat_time_start = song_time_elapsed
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("ui_accept"):
|
if event.is_action_pressed("start"):
|
||||||
if is_running == false:
|
if is_running == false:
|
||||||
start_time = Time.get_ticks_usec()
|
start_time = Time.get_ticks_usec()
|
||||||
print("start time: %s" % start_time)
|
print("start time: %s" % start_time)
|
||||||
is_running = true
|
is_running = true
|
||||||
click_track.play()
|
target_audio.play()
|
||||||
else:
|
else:
|
||||||
click_track.stop()
|
target_audio.stop()
|
||||||
is_running = false
|
is_running = false
|
||||||
end_time = Time.get_ticks_usec()
|
end_time = Time.get_ticks_usec()
|
||||||
print("end_time: %s" % end_time)
|
print("end_time: %s" % end_time)
|
||||||
|
song_started.emit()
|
||||||
|
|
||||||
#func _physics_process(delta: float) -> void:
|
#func _physics_process(delta: float) -> void:
|
||||||
#pass
|
#pass
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
[gd_scene format=3 uid="uid://ojisu2jrshsp"]
|
[gd_scene format=3 uid="uid://ojisu2jrshsp"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://bhbfogebu1di5" path="res://rhythm_manager.gd" id="1_0wx20"]
|
[ext_resource type="Script" uid="uid://bhbfogebu1di5" path="res://rhythm_manager.gd" id="1_0wx20"]
|
||||||
[ext_resource type="AudioStream" uid="uid://b8n6p428csquv" path="res://assets/audio/full/eine-kleine-click.wav" id="2_6v8l0"]
|
[ext_resource type="PackedScene" uid="uid://dduyumwk5v1ge" path="res://click_track.tscn" id="2_6v8l0"]
|
||||||
|
|
||||||
[node name="RhythmManager" type="Node2D" unique_id=2036637300]
|
[node name="RhythmManager" type="Node2D" unique_id=2036637300 node_paths=PackedStringArray("target_audio")]
|
||||||
script = ExtResource("1_0wx20")
|
script = ExtResource("1_0wx20")
|
||||||
|
target_audio = NodePath("")
|
||||||
|
|
||||||
[node name="RhythmUI" type="Control" parent="." unique_id=510351076]
|
[node name="RhythmUI" type="Control" parent="." unique_id=510351076]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
@ -47,7 +48,7 @@ text = "00000"
|
|||||||
[node name="VolumeContainer" type="HBoxContainer" parent="RhythmUI/VBoxContainer" unique_id=845038304]
|
[node name="VolumeContainer" type="HBoxContainer" parent="RhythmUI/VBoxContainer" unique_id=845038304]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="VolumeLabel" type="Label" parent="RhythmUI/VBoxContainer/VolumeContainer" unique_id=1552250086]
|
[node name="VolumeLabelLeft" type="Label" parent="RhythmUI/VBoxContainer/VolumeContainer" unique_id=1552250086]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Volume L: "
|
text = "Volume L: "
|
||||||
|
|
||||||
@ -56,15 +57,20 @@ unique_name_in_owner = true
|
|||||||
custom_minimum_size = Vector2(0, 24)
|
custom_minimum_size = Vector2(0, 24)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
min_value = -200.0
|
min_value = -100.0
|
||||||
max_value = 0.0
|
max_value = 0.0
|
||||||
fill_mode = 1
|
step = 0.1
|
||||||
show_percentage = false
|
show_percentage = false
|
||||||
|
|
||||||
|
[node name="VolumeValueLeft" type="Label" parent="RhythmUI/VBoxContainer/VolumeContainer" unique_id=1495628968]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
text = "-00.0"
|
||||||
|
|
||||||
[node name="VolumeContainerRight" type="HBoxContainer" parent="RhythmUI/VBoxContainer" unique_id=1505527639]
|
[node name="VolumeContainerRight" type="HBoxContainer" parent="RhythmUI/VBoxContainer" unique_id=1505527639]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="VolumeLabel" type="Label" parent="RhythmUI/VBoxContainer/VolumeContainerRight" unique_id=96518109]
|
[node name="VolumeLabelRight" type="Label" parent="RhythmUI/VBoxContainer/VolumeContainerRight" unique_id=96518109]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Volume R: "
|
text = "Volume R: "
|
||||||
|
|
||||||
@ -73,11 +79,15 @@ unique_name_in_owner = true
|
|||||||
custom_minimum_size = Vector2(0, 24)
|
custom_minimum_size = Vector2(0, 24)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
min_value = -200.0
|
min_value = -100.0
|
||||||
max_value = 0.0
|
max_value = 0.0
|
||||||
fill_mode = 1
|
step = 0.1
|
||||||
show_percentage = false
|
show_percentage = false
|
||||||
|
|
||||||
[node name="ClickTrack" type="AudioStreamPlayer2D" parent="." unique_id=875092300]
|
[node name="VolumeValueRight" type="Label" parent="RhythmUI/VBoxContainer/VolumeContainerRight" unique_id=1882589387]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
text = "-00.0"
|
||||||
|
|
||||||
|
[node name="ClickTrack" parent="." unique_id=1931221522 instance=ExtResource("2_6v8l0")]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
stream = ExtResource("2_6v8l0")
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user