21 Individual Fall Speed
In this chapter, we will add individual fall speed to Note.
Calculate Fall Time from BPM
Individual fall speed is another common feature in rhythm games. Each note may fall at a different speed. Some games determine a note's fall speed from the BPM, while others adjust it manually to create visual effects.
In our engine, fall speed will vary with BPM.
Currently, every Note has the same fall speed because visual_time.start is fixed at 1 second before visual_time.end. To vary fall speed, we can vary the fall time.
Open guide/play/note.py and update the assignment to self.visual_time.start in Note.preprocess. beat_to_bpm(self.beat) returns the BPM at the Note's beat. At a constant BPM, one beat lasts 60 / BPM seconds. We use twice that value, 120 / BPM, as the baseline fall duration. The baseline is 1 second at 120 BPM and 0.5 seconds at 240 BPM. Time-scale and nearby BPM changes can affect the actual fall time. Use this calculation:
python
from sonolus.script.timing import beat_to_bpm, beat_to_time, time_to_scaled_time
class Note(PlayArchetype):
# ...
def preprocess(self):
# ...
self.visual_time.end = time_to_scaled_time(self.target_time)
self.visual_time.start = self.visual_time.end - 120 / beat_to_bpm(self.beat)
# ...
# ...Checkpoint
Run the level through the BPM change near the beginning. After the tempo doubles, Notes should cross the lane in about half the time.