45 lines
795 B
GDScript3
45 lines
795 B
GDScript3
|
|
#@tool
|
||
|
|
#@icon(icon_path: String)
|
||
|
|
class_name RhythmManager
|
||
|
|
extends Node2D
|
||
|
|
## Documentation comments
|
||
|
|
|
||
|
|
## signal
|
||
|
|
## enum
|
||
|
|
## const
|
||
|
|
|
||
|
|
@export var tempo: int = 120
|
||
|
|
@export var beats_per_measure: int = 4
|
||
|
|
|
||
|
|
var seconds_per_beat: float
|
||
|
|
var seconds_elapsed: float = 0.0
|
||
|
|
var is_running: bool = false
|
||
|
|
|
||
|
|
@onready var click_track: AudioStreamPlayer2D = %ClickTrack
|
||
|
|
|
||
|
|
## OVERRIDES
|
||
|
|
|
||
|
|
func _ready() -> void:
|
||
|
|
seconds_per_beat = 60.0/float(tempo)
|
||
|
|
print(seconds_per_beat)
|
||
|
|
|
||
|
|
func _process(_delta: float) -> void:
|
||
|
|
if is_running:
|
||
|
|
seconds_elapsed = Time.get_ticks_msec() / 1000.0
|
||
|
|
|
||
|
|
func _input(event: InputEvent) -> void:
|
||
|
|
if event.is_action_pressed("ui_accept"):
|
||
|
|
is_running = true
|
||
|
|
click_track.play()
|
||
|
|
|
||
|
|
#func _physics_process(delta: float) -> void:
|
||
|
|
#pass
|
||
|
|
|
||
|
|
## CORE
|
||
|
|
|
||
|
|
## PRIVATE/HELPER
|
||
|
|
|
||
|
|
## RECEIVERS
|
||
|
|
|
||
|
|
## SETTERS/GETTERS
|