Sonolus Wiki

20. Life

In this chapter, we will set up life and life UI.

Archetype Life Increment

For each archetype, we can reward or punish player for hitting a judgment type.

In our engine, we are going to reward player for hitting a Perfect by 10 life, and punish player for hitting a Miss by 100 life.

const noteLife = ArchetypeLife.of(archetypes.noteIndex)

const preprocess = [
    // ...
    noteLife.perfectLifeIncrement.set(10),
    noteLife.missLifeIncrement.set(-100),
]
const noteLife = ArchetypeLife.of(archetypes.noteIndex)

const preprocess = [
    // ...
    noteLife.perfectLifeIncrement.set(10),
    noteLife.missLifeIncrement.set(-100),
]

Consecutive Judgment Type Life Increment

Similar to score, we can also reward or punish player for hitting consecutive judgment type or above.

In our engine, we are going to reward player for hitting 10 consecutive Perfects by 50 life.

const preprocess = [
    // ...
    ConsecutivePerfectLife.set(50, 10),
]
const preprocess = [
    // ...
    ConsecutivePerfectLife.set(50, 10),
]

Secondary Metric UI

Similar to primary metric UI, there are also secondary metric bar and secondary metric value UI, which is often used to display life.

const preprocess = [
    // ...
    UISecondaryMetricBar.set(
        Subtract(ScreenAspectRatio, 0.05),
        0.75,
        1,
        1,
        0.75,
        0.15,
        0,
        1,
        HorizontalAlign.Left,
        true
    ),
    UISecondaryMetricValue.set(
        Subtract(ScreenAspectRatio, 0.085),
        0.715,
        1,
        1,
        0,
        0.08,
        0,
        1,
        HorizontalAlign.Right,
        false
    ),
    // ...
]
const preprocess = [
    // ...
    UISecondaryMetricBar.set(
        Subtract(ScreenAspectRatio, 0.05),
        0.75,
        1,
        1,
        0.75,
        0.15,
        0,
        1,
        HorizontalAlign.Left,
        true
    ),
    UISecondaryMetricValue.set(
        Subtract(ScreenAspectRatio, 0.085),
        0.715,
        1,
        1,
        0,
        0.08,
        0,
        1,
        HorizontalAlign.Right,
        false
    ),
    // ...
]