Initial commit. Implement music sync features.
This commit is contained in:
26
rhythm_game/music_sync/beat_update.gd
Normal file
26
rhythm_game/music_sync/beat_update.gd
Normal file
@@ -0,0 +1,26 @@
|
||||
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
|
||||
Reference in New Issue
Block a user