Skip to content

13 Test Level ​

This chapter builds a playable test level from the prepared chart and assets.

Level Assets ​

The template includes a cover image and background music (BGM) under resources/levels/patience:

  • cover.jpg is the image shown for the level.
  • bgm.mp3 is the music played during the level.

Chart ​

A test chart is also prepared in guide/chart.py. It contains BPMS, NOTE_BEATS, and TIMESCALES, which chapter 20 will use.

Now we can generate the BPM change and Note entities from BPMS and NOTE_BEATS. A Sonolus.py level stores typed archetype instances in its entity list, so we can construct them directly. Replace the contents of guide/level.py with:

python
from sonolus.script.level import BpmChange, Level, LevelData

from guide.chart import BPMS, NOTE_BEATS
from guide.play.initialization import Initialization
from guide.play.note import Note
from guide.play.stage import Stage

guide_level = Level(
    name="guide",
    title="Patience",
    artists="More Plastic & VinDon",
    author="ntsu",
    description=(
        "Song: More Plastic & VinDon - Patience\n"
        "Music provided by NoCopyrightSounds\n"
        "Free Download/Stream: http://NCS.io/Patience\n"
        "Watch: https://youtu.be/Lxf65uhlR6s"
    ),
    cover="levels/patience/cover.jpg",
    bgm="levels/patience/bgm.mp3",
    data=LevelData(
        bgm_offset=0,
        entities=[
            Initialization(),
            Stage(),
            *(BpmChange(beat=beat, bpm=bpm) for beat, bpm in BPMS),
            *(Note(beat=beat) for beat in NOTE_BEATS),
        ],
    ),
)


def load_levels():
    yield guide_level

Because Note.beat uses StandardImport.BEAT, constructing Note(beat=beat) writes the standard beat field that Sonolus expects. The note drawing code places every note in the center lane.

Checkpoint ​

Open Patience. Its cover should appear in the level list. During play, the BGM should play and the center lane should contain notes from the test chart.