#How would music based combat work?
2 messages · Page 1 of 1 (latest)
Let's say for testing you have a 1 beat every 4 seconds.
Pseudo-code
var current_count: float
signal beat()
func process(delta):
current_count += delta
if current_count >= 4
beat.emit()
#Set timer back to 0, plus any leftover time from that frame
current_count = current_count - 4
Now, whenever your player attacks, send a signal to a "BeatMatcher" class (but don't actually deal any damage).
The BeatMatcher holds on to that info, and if a beat signal comes in or already came in within say, 0.2 of a second, increase damage of the attack, and then apply it.