Skip to content

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. A tempo of 120 BPM gives a 1-second fall time. Because the formula divides by the current BPM, 240 BPM gives a 0.5-second fall time. beat_to_bpm(self.beat) returns the BPM at the Note's beat:

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.