16. Test Level
In this chapter, we will set up a simple level to better play test with.
Level Cover and Bgm
Sonolus.js internally uses sonolus-express to power its development server, and serve
returns an instance of the Sonolus
class which you can use it to alter the behavior of dev server.
In this guide, we are simply going to use online bgm and cover for testing purpose:
const sonolus = serve(buildOutput)
const level = sonolus.db.levels[0]
level.cover = {
type: 'LevelCover',
hash: '',
url: 'https://sonolus.com/assets/jacket066.png',
}
level.bgm = {
type: 'LevelBgm',
hash: '',
url: 'https://sonolus.com/assets/bgm066.mp3',
}
const sonolus = serve(buildOutput)
const level = sonolus.db.levels[0]
level.cover = {
type: 'LevelCover',
hash: '',
url: 'https://sonolus.com/assets/jacket066.png',
}
level.bgm = {
type: 'LevelBgm',
hash: '',
url: 'https://sonolus.com/assets/bgm066.mp3',
}
Chart
We are also going to use a chart for the level, it's simply raw times of notes in a text file.
In level data we are going to parse it and convert it into entities:
export const levelData: LevelData = {
entities: [
// ...
...readFileSync(__dirname + '/chart.txt', 'utf-8')
.split('\n')
.map((time) => ({
archetype: archetypes.noteIndex,
data: {
index: 0,
values: [+time],
},
})),
],
}
export const levelData = {
entities: [
// ...
...readFileSync(__dirname + '/chart.txt', 'utf-8')
.split('\n')
.map((time) => ({
archetype: archetypes.noteIndex,
data: {
index: 0,
values: [+time],
},
})),
],
}
If you have trouble understanding it there's no sweat, it's only for testing purpose.