27 lines
475 B
GDScript3
27 lines
475 B
GDScript3
|
|
class_name BeatUpdate
|
||
|
|
|
||
|
|
## Beat this frame.
|
||
|
|
var current: float
|
||
|
|
|
||
|
|
## Beat last frame.
|
||
|
|
var previous: float
|
||
|
|
|
||
|
|
|
||
|
|
## Beat updated forward in time.
|
||
|
|
func forward() -> bool:
|
||
|
|
return current > previous
|
||
|
|
|
||
|
|
|
||
|
|
## Beat updated backward in time.
|
||
|
|
func backward() -> bool:
|
||
|
|
return current < previous
|
||
|
|
|
||
|
|
|
||
|
|
func new_beat() -> bool:
|
||
|
|
return floori(previous) != floori(current)
|
||
|
|
|
||
|
|
|
||
|
|
func _init(current_beat: float = 0.0, previous_beat: float = 0.0) -> void:
|
||
|
|
current = current_beat
|
||
|
|
previous = previous_beat
|