Early developmentPre-1.0: syntax may change.Release historyGitHub
Pixel 3D

Marble Run

Roll through six courses above a floating factory. Bank around corners, jump gaps and spikes, and spend charge cells to blast sentries.

Rotate your phone to play in landscape.

Try the Pocket palette or switch on the experimental GPU renderer. The game shows actual FPS as you change the resolution and frame rate.

On a phone, steer with the stick, use JUMP and CHARGE, and tap the pause button in the game. Use the pause menu to leave fullscreen.

Open game in a new tab
Marble Run

Loading game…

Game license

View source code
marble_run.rune
#!RUNE
import "models.rune"
import "cloudworks.rune"
import "hud.rune"
import "logic.rune"
import "menus.rune"
import "title.rune"
import "levels.rune"
import "controls.rune"
import "sound.rune"
import "shell.rune"

@App
name = Marble Run
type = pixel-3d
runtime = hybrid
scene = marble_run
resolution = [384,240]
tick_rate = 30
port = 3027
shell = marble_cabinet

@Perspective/downhill
fov = 72

@Scene/marble_run
logic = marble_run
map = valley
camera = camera
perspective = downhill
things = ["factory","track","scenery","enemies","spikes","shadow","avatar","stripe","charge_orbs","fragments","goal"]
controls = marble_run
ui = ui
title_scene = marble_title_scene
persistence = {"key":"marble-run-campaign-v1","state":"progress"}
pause_ui = pause_ui
restart_action = return_to_title
click_to_start = false
mouse_look = false
@Map/valley
sky = {
    "below": "#4d405a",
    "cloud": "#ddb5aa",
    "horizon": "#edac83",
    "seed": 87,
    "speed": 0.16,
    "zenith": "#423958"
}
legend = {".":{}}
grid:
    "..."
    "..."
    "..."

@Page/marble_run
logic = marble_run
view:
    canvas data-rune-pixel-3d=true
cloudworks.rune
# Scenic models only. They sit below the playable decks and have no collision.
@Logic/marble_run
state:
    factory = [
        {"x": 18, "y": -16, "z": -24, "angle": 15, "model": "cloudworks/tower"},
        {"x": 37, "y": 21, "z": -23, "angle": 30, "model": "cloudworks/mill"},
        {"x": 52, "y": -14, "z": -30, "angle": 0, "model": "cloudworks/trestle"},
        {"x": 75, "y": -14, "z": -29, "angle": 45, "model": "cloudworks/tower"},
        {"x": 70, "y": 35, "z": -29, "angle": 55, "model": "cloudworks/trestle"},
        {"x": 86, "y": 59, "z": -28, "angle": 0, "model": "cloudworks/mill"},
        {"x": 108, "y": 18, "z": -31, "angle": 80, "model": "cloudworks/tower"},
        {"x": 128, "y": 38, "z": -29, "angle": 90, "model": "cloudworks/trestle"},
        {"x": 124, "y": -23, "z": -30, "angle": 40, "model": "cloudworks/mill"},
        {"x": -14, "y": 26, "z": -22, "angle": 90, "model": "cloudworks/tower"}
    ]

@Palette/cloudworks
colors = {"h":"#9d7884","m":"#ac8285","r":"#bd938e","s":"#886d81","w":"#d1a394"}

@Model/cloudworks/tower
palette = cloudworks
unit = 1
blocks:
    {"from":[-5,-5,0],"size":[10,10,5],"color":"s"}
    {"from":[-4,-4,5],"size":[8,8,7],"color":"h"}
    {"from":[-5,-5,12],"size":[10,10,1],"color":"r"}
    {"from":[-3,-3,13],"size":[6,6,3],"color":"m"}
    {"from":[-2,-5,8],"size":[4,1,1],"color":"w"}
shapes:
    {"type":"cylinder","center":[1,1,16],"radius":1.5,"height":6,"color":"s"}
    {"type":"cylinder","center":[1,1,19],"radius":1.8,"height":1,"color":"r"}

@Model/cloudworks/mill
palette = cloudworks
unit = 1
blocks:
    {"from":[-8,-5,0],"size":[16,10,4],"color":"s"}
    {"from":[-7,-4,4],"size":[14,8,4],"color":"h"}
    {"from":[-8,-5,8],"size":[16,10,1],"color":"r"}
    {"from":[-6,-5,6],"size":[2,1,1],"color":"w"}
    {"from":[-2,-5,6],"size":[2,1,1],"color":"w"}
    {"from":[2,-5,6],"size":[2,1,1],"color":"w"}
    {"from":[-6,-1,12],"size":[12,2,1],"color":"m"}
    {"from":[-1,-6,12],"size":[2,12,1],"color":"m"}
shapes:
    {"type":"cylinder","center":[0,0,11],"radius":5,"height":2,"color":"h"}
    {"type":"cylinder","center":[0,0,13],"radius":2,"height":2,"color":"w"}

@Model/cloudworks/trestle
palette = cloudworks
unit = 1
blocks:
    {"from":[-11,-2,0],"size":[2,4,11],"color":"s"}
    {"from":[9,-2,0],"size":[2,4,11],"color":"s"}
    {"from":[-12,-3,11],"size":[24,6,1],"color":"m"}
    {"from":[-12,-3,12],"size":[24,1,1],"color":"h"}
    {"from":[-12,2,12],"size":[24,1,1],"color":"h"}
controls.rune
@Controls/marble_run
keys:
    KeyW -> forward
    ArrowUp -> forward
    KeyS -> back
    ArrowDown -> back
    KeyA -> left
    ArrowLeft -> left
    KeyD -> right
    ArrowRight -> right
    Space -> jump
    KeyX -> charge
    ShiftLeft -> charge
    ShiftRight -> charge
commands:
    Enter -> host.advance
    KeyP -> host.pause
    KeyM -> host.mute
    KeyF -> host.fullscreen
    KeyT -> return_to_title
    KeyL -> open_selector
gamepad:
    Axis0 -> {"input":"move_x","deadzone":0.15}
    Axis1 -> {"input":"move_y","invert":true,"deadzone":0.15}
    Button0 -> jump
    Button2 -> charge
    Button7 -> {"input":"charge","threshold":0.3}
    Button8 -> {"command":"host.advance"}
    Button9 -> {"command":"host.pause"}
touch = {
    "buttons": [
        {"id":"jump","input":"jump","label":"JUMP","offset":[12,16],"size":64},
        {"id":"charge","input":"charge","label":"CHARGE","offset":[88,16],"size":64},
        {
            "id": "pause",
            "command": "host.pause",
            "label": "II",
            "aria_label": "Pause game",
            "anchor": "top-right",
            "offset": [12,12],
            "size": 44
        }
    ],
    "joystick": {"size":84,"x":"move_x","y":"move_y"},
    "visible": "touch_ready"
}
hud.rune
# Game-owned HUD icons. Dots stay transparent over the 3D scene.
@Palette/marble_hud
colors = {
    ".": "transparent",
    "c": "#68e1e8",
    "g": "#f7d68b",
    "k": "#142b38",
    "o": "#d59968",
    "s": "#67838d",
    "t": "#277eab",
    "w": "#e5fbdf"
}

@Sprite/marble/hud/marble_full
palette = marble_hud
size = [9,9]
origin = [0,0]
pixels:
    "..kkkkk.."
    ".kccwcck."
    "kcwwccctk"
    "kcwcccctk"
    "kcccccctk"
    "kcccctttk"
    "kcttttttk"
    ".ktttttk."
    "..kkkkk.."

@Sprite/marble/hud/marble_empty
palette = marble_hud
size = [9,9]
origin = [0,0]
pixels:
    "..kkkkk.."
    ".ksssssk."
    "ks.....sk"
    "ks.....sk"
    "ks.....sk"
    "ks.....sk"
    "ks.....sk"
    ".ksssssk."
    "..kkkkk.."

@Sprite/marble/hud/cell_full
palette = marble_hud
size = [7,11]
origin = [0,0]
pixels:
    "..kkk.."
    ".kgggk."
    "kkkkkkk"
    "kgwwwgk"
    "kgggggk"
    "kgggggk"
    "kgwwwgk"
    "kgggggk"
    "kgooogk"
    "koooook"
    "kkkkkkk"

@Sprite/marble/hud/cell_empty
palette = marble_hud
size = [7,11]
origin = [0,0]
pixels:
    "..kkk.."
    ".ksssk."
    "kkkkkkk"
    "ks...sk"
    "ks...sk"
    "ks...sk"
    "ks...sk"
    "ks...sk"
    "ks...sk"
    "ksssssk"
    "kkkkkkk"

@Sprite/marble/hud/bolt_charge
palette = marble_hud
size = [9,11]
origin = [0,0]
pixels:
    ".....kk.."
    "....kgk.."
    "...kggk.."
    "..kggk..."
    ".kgggkkk."
    "kgggggggk"
    ".kkkgggk."
    "...kggk.."
    "..kggk..."
    "..kgk...."
    "..kk....."

@Sprite/marble/hud/bolt_ready
palette = marble_hud
size = [9,11]
origin = [0,0]
pixels:
    ".....kk.."
    "....kck.."
    "...kcck.."
    "..kcck..."
    ".kccckkk."
    "kccccccck"
    ".kkkccck."
    "...kcck.."
    "..kcck..."
    "..kck...."
    "..kk....."

@Sprite/marble/hud/bolt_empty
palette = marble_hud
size = [9,11]
origin = [0,0]
pixels:
    ".....kk.."
    "....ksk.."
    "...kssk.."
    "..kssk..."
    ".kssskkk."
    "ksssssssk"
    ".kkksssk."
    "...kssk.."
    "..kssk..."
    "..ksk...."
    "..kk....."

@Sprite/marble/hud/hourglass
palette = marble_hud
size = [9,11]
origin = [0,0]
pixels:
    "kkkkkkkkk"
    "ktttttttk"
    ".kswwwsk."
    "..kswsk.."
    "...ksk..."
    "....k...."
    "...kgk..."
    "..kgggk.."
    ".kgggggk."
    "ktttttttk"
    "kkkkkkkkk"
levels.rune
@Logic/marble_run
action define_course:
    track = []
    surfaces = []
    scenery = []
    enemies = []
    spikes = []
    gaps = []
    route = []
    waypoints = []
    corner_count = 0
    pipe_count = 0
    max_speed = min(0.38,0.34+(level-1)*0.02)
    if level == 1:
        level_name = "01 / COPPER CASCADE"
        start_height = 10
        checkpoint_x = 36.5
        checkpoint_z = 6
        call begin_path
        call deck 3, "marble/deck"
        call ramp 3, "marble/slope"
        call deck 3, "marble/deck"
        call gap 3, 3
        call deck 4, "marble/landing"
        call corner 90
        call half_pipe
        call ramp 4, "marble/wide_slope"
        call deck 4, "marble/landing"
        call finish_path
        call sentry_at 18, 1.6, 2, 0
        call sentry_at 41.5, 1.6, 2, 120
        call sentry_at 74, 1.5, 2, 240
        call spike_at 28, 1.8
        call spike_at 86, -2.5
        call spike_at 86, 2.5
    if level == 2:
        level_name = "02 / GLASS SPINE"
        start_height = 14
        checkpoint_x = 37
        checkpoint_z = 10
        call begin_path
        call deck 2.25, "marble/deck_glass"
        call ramp 2.25, "marble/slope_glass"
        call deck 2.25, "marble/deck_glass"
        call gap 3.5, 2.25
        call deck 2.25, "marble/deck_glass"
        call corner 90
        call half_pipe
        call deck 2.25, "marble/deck_glass"
        call gap 4, 2.25
        call deck 2.5, "marble/deck_finish"
        call corner -90
        call ramp 1.75, "marble/slope_spine"
        call deck 2.5, "marble/deck_finish"
        call finish_path
        call sentry_at 18, 1.2, 3, 0
        call sentry_at 60, 1.2, 3, 90
        call sentry_at 108, 0.95, 3, 180
        call sentry_at 113, 1.5, 3, 270
        call spike_at 28, -1.5
        call spike_at 61, -2.3
        call spike_at 61, 2.3
        call spike_at 102, -1
        call spike_at 102, 0
        call spike_at 102, 1
    if level == 3:
        level_name = "03 / TEMPEST RIDGE"
        start_height = 18
        checkpoint_x = 37.5
        checkpoint_z = 14
        call begin_path
        call deck 2, "marble/deck_ridge"
        call ramp 1.75, "marble/slope_spine"
        call deck 1.75, "marble/deck_spine"
        call gap 4, 1.75
        call deck 2, "marble/deck_ridge"
        call corner 90
        call half_pipe
        call deck 1.75, "marble/deck_spine"
        call gap 4.25, 1.75
        call deck 2, "marble/deck_ridge"
        call corner 90
        call ramp 1.75, "marble/slope_spine"
        call deck 2, "marble/deck_ridge"
        call corner -90
        call half_pipe
        call deck 1.5, "marble/deck_storm"
        call gap 4.5, 1.5
        call deck 2, "marble/deck_ridge"
        call ramp 1.5, "marble/slope_storm"
        call deck 2, "marble/deck_ridge"
        call finish_path
        call sentry_at 18, 1, 4, 0
        call sentry_at 70, 1, 4, 72
        call sentry_at 110, 0.8, 4, 144
        call sentry_at 138, 1.2, 4, 216
        call sentry_at 178.5, 1.1, 4, 288
        call spike_at 28, 1.2
        call spike_at 60, 0
        call spike_at 104, -1
        call spike_at 104, 0
        call spike_at 104, 1
        call spike_at 137, -2.3
        call spike_at 137, 2.3
        call spike_at 171, -0.9
        call spike_at 171, 0
        call spike_at 171, 0.9

    if level == 4:
        level_name = "04 / AURORA SWITCHBACK"
        start_height = 18
        checkpoint_x = 37
        checkpoint_z = 14
        call begin_path
        call deck 2.25, "marble/deck_glass"
        call ramp 2.25, "marble/slope_glass"
        call deck 2.25, "marble/deck_glass"
        call gap 3.5, 2.25
        call deck 2.5, "marble/deck_finish"
        call corner -90
        call half_pipe
        call deck 2.25, "marble/deck_glass"
        call gap 3.5, 2.25
        call deck 2.5, "marble/deck_finish"
        call corner 90
        call ramp 1.75, "marble/slope_spine"
        call corner 90
        call deck 2, "marble/deck_ridge"
        call gap 4, 2
        call deck 2.5, "marble/deck_finish"
        call corner -90
        call ramp 1.75, "marble/slope_spine"
        call deck 2.5, "marble/deck_finish"
        call finish_path
        call sentry_at 18, 1.2, 3.5, 0
        call sentry_at 60, 1.2, 3.5, 90
        call sentry_at 106, 0.8, 3.5, 180
        call sentry_at 154, 0.8, 3.5, 240
        call sentry_at 166, 1.2, 3.5, 300
        call spike_at 28, -1.5
        call spike_at 61, -2.3
        call spike_at 61, 2.3
        call spike_at 103, -1
        call spike_at 103, 0
        call spike_at 103, 1
        call spike_at 155, -1
        call spike_at 155, 0
        call spike_at 155, 1
    if level == 5:
        level_name = "05 / EMBER FOUNDRY"
        start_height = 22
        checkpoint_x = 37.5
        checkpoint_z = 18
        call begin_path
        call deck 2, "marble/deck_ridge"
        call ramp 1.75, "marble/slope_spine"
        call deck 1.75, "marble/deck_spine"
        call gap 4, 1.75
        call deck 2, "marble/deck_ridge"
        call corner 90
        call half_pipe
        call deck 1.75, "marble/deck_spine"
        call gap 4, 1.75
        call deck 2, "marble/deck_ridge"
        call corner 90
        call ramp 1.5, "marble/slope_storm"
        call deck 2, "marble/deck_ridge"
        call gap 4, 2
        call deck 2, "marble/deck_ridge"
        call corner -90
        call half_pipe
        call deck 1.75, "marble/deck_spine"
        call gap 4, 1.75
        call deck 2, "marble/deck_ridge"
        call corner -90
        call ramp 1.75, "marble/slope_spine"
        call deck 2.5, "marble/deck_finish"
        call finish_path
        call sentry_at 18, 1, 4, 0
        call sentry_at 60, 1.2, 4, 60
        call sentry_at 90, 1.3, 4, 120
        call sentry_at 108, 0.8, 4, 180
        call sentry_at 150, 1.2, 4, 240
        call sentry_at 196, 0.8, 4, 300
        call spike_at 28, 1.2
        call spike_at 104, -1
        call spike_at 104, 0
        call spike_at 104, 1
        call spike_at 150, -2.3
        call spike_at 150, 2.3
        call spike_at 192, -1
        call spike_at 192, 0
        call spike_at 192, 1
    if level == 6:
        level_name = "06 / CELESTIAL CROWN"
        start_height = 26
        checkpoint_x = 37.5
        checkpoint_z = 22
        call begin_path
        call deck 2, "marble/deck_ridge"
        call ramp 1.75, "marble/slope_spine"
        call deck 1.75, "marble/deck_spine"
        call gap 4, 1.75
        call deck 2, "marble/deck_ridge"
        call corner 90
        call half_pipe
        call deck 1.75, "marble/deck_spine"
        call gap 4, 1.75
        call deck 2, "marble/deck_ridge"
        call corner -90
        call ramp 1.75, "marble/slope_spine"
        call deck 2, "marble/deck_ridge"
        call gap 4, 2
        call deck 2, "marble/deck_ridge"
        call corner -90
        call half_pipe
        call deck 1.75, "marble/deck_spine"
        call gap 4, 1.75
        call deck 2, "marble/deck_ridge"
        call corner 90
        call ramp 1.5, "marble/slope_storm"
        call deck 1.75, "marble/deck_spine"
        call gap 4, 1.75
        call deck 2, "marble/deck_ridge"
        call corner 90
        call ramp 1.75, "marble/slope_spine"
        call deck 2.5, "marble/deck_finish"
        call finish_path
        call sentry_at 18, 1, 4.5, 0
        call sentry_at 60, 1.2, 4.5, 50
        call sentry_at 90, 1.3, 4.5, 100
        call sentry_at 108, 0.8, 4.5, 150
        call sentry_at 150, 1.2, 4.5, 200
        call sentry_at 194, 0.8, 4.5, 250
        call sentry_at 240, 0.8, 4.5, 300
        call spike_at 28, 1.2
        call spike_at 60, 0
        call spike_at 104, -1
        call spike_at 104, 0
        call spike_at 104, 1
        call spike_at 150, -2.3
        call spike_at 150, 2.3
        call spike_at 192, -1
        call spike_at 192, 0
        call spike_at 192, 1
        call spike_at 236, -1
        call spike_at 236, 0
        call spike_at 236, 1

# The path cursor authors both rendered geometry and oriented collision planes.
action begin_path:
    build_x = 0
    build_y = 0
    build_z = start_height
    build_angle = 0
    build_s = 0

action lane(length,slope,half,kind):
    route.push(
        {
            "x": build_x,
            "y": build_y,
            "z": build_z,
            "angle": build_angle,
            "dx": cos(build_angle),
            "dy": sin(build_angle),
            "s": build_s,
            "length": length,
            "slope": slope,
            "half": half,
            "kind": kind
        }
    )
    build_x += cos(build_angle)*length
    build_y += sin(build_angle)*length
    build_z += slope*length
    build_s += length
    waypoints.push({"x": build_x, "y": build_y, "s": build_s, "kind": kind})

action plane(length,slope,half,pipe):
    dx = cos(build_angle)
    dy = sin(build_angle)
    surfaces.push(
        {
            "x": build_x,
            "y": build_y,
            "z": build_z,
            "angle": build_angle,
            "dx": dx,
            "dy": dy,
            "length": length,
            "slope": slope,
            "half": half,
            "pipe": pipe,
            "min_x": min(build_x, build_x + dx * length) - abs(dy) * half - 0.000001,
            "max_x": max(build_x, build_x + dx * length) + abs(dy) * half + 0.000001,
            "min_y": min(build_y, build_y + dy * length) - abs(dx) * half - 0.000001,
            "max_y": max(build_y, build_y + dy * length) + abs(dx) * half + 0.000001
        }
    )

action deck(half,model):
    call plane 8, 0, half, false
    track.push({"x": build_x, "y": build_y, "z": build_z, "angle": build_angle, "model": model})
    call lane 8, 0, half, "deck"

action ramp(half,model):
    call plane 16, -0.25, half, false
    track.push(
        {
            "x": build_x + cos(build_angle) * 16,
            "y": build_y + sin(build_angle) * 16,
            "z": build_z - 4,
            "angle": build_angle + 180,
            "model": model
        }
    )
    call lane 16, -0.25, half, "ramp"

action gap(width,half):
    gaps.push({"s": build_s, "landing": build_s + width})
    scenery.push(
        {
            "x": build_x - cos(build_angle) + sin(build_angle) * (half - 0.1),
            "y": build_y - sin(build_angle) - cos(build_angle) * (half - 0.1),
            "z": build_z,
            "model": "marble/pillar"
        }
    )
    scenery.push(
        {
            "x": build_x - cos(build_angle) - sin(build_angle) * (half - 0.1),
            "y": build_y - sin(build_angle) + cos(build_angle) * (half - 0.1),
            "z": build_z,
            "model": "marble/pillar"
        }
    )
    call lane width, 0, half, "gap"

action corner(turn):
    # An eight-tile square gives room to slow down and cut the inside of the bend.
    center_x = build_x+cos(build_angle)*4
    center_y = build_y+sin(build_angle)*4
    surfaces.push(
        {
            "x": center_x - 4,
            "y": center_y,
            "z": build_z,
            "angle": 0,
            "dx": 1,
            "dy": 0,
            "min_x": center_x - 4.000001,
            "max_x": center_x + 4.000001,
            "min_y": center_y - 4.000001,
            "max_y": center_y + 4.000001,
            "length": 8,
            "slope": 0,
            "half": 4,
            "pipe": false
        }
    )
    track.push({"x": center_x, "y": center_y, "z": build_z, "model": "marble/corner"})
    call lane 4, 0, 4, "turn"
    build_angle += turn
    track.push(
        {
            "x": build_x,
            "y": build_y,
            "z": build_z + 0.03,
            "angle": build_angle,
            "model": "marble/arrow"
        }
    )
    call lane 4, 0, 4, "turn"
    corner_count += 1

action half_pipe:
    call plane 16, 0, 3, true
    for slab in range(0,2):
        track.push(
            {
                "x": build_x + cos(build_angle) * slab * 8,
                "y": build_y + sin(build_angle) * slab * 8,
                "z": build_z,
                "angle": build_angle,
                "model": "marble/deck"
            }
        )
    # Four matching planes on each bank approximate a rounded U with a flat trough.
    for strip in range(0,4):
        for band in range(0,4):
            for sign in [-1,1]:
                across = sign*(0.5+band*0.625)
                along = strip*4+2
                track.push(
                    {
                        "x": build_x + cos(build_angle) * along - sin(build_angle) * across,
                        "y": build_y + sin(build_angle) * along + cos(build_angle) * across,
                        "z": build_z + band * band * 0.125,
                        "angle": build_angle + sign * 90,
                        "model": "marble/pipe_bank_" + band
                    }
                )
    call lane 16, 0, 3, "pipe"
    pipe_count += 1

action route_point(distance):
    for segment in route:
        if distance >= segment.s && distance <= segment.s+segment.length:
            along = distance-segment.s
            route_x = segment.x+segment.dx*along
            route_y = segment.y+segment.dy*along
            route_z = segment.z+segment.slope*along
            route_angle = segment.angle
            route_pipe = segment.kind == "pipe"

action finish_path:
    course_length = build_s
    call route_point build_s-3
    goal.x = route_x
    goal.y = route_y
    goal.z = route_z
    call route_point checkpoint_x
    checkpoint_y = route_y
    checkpoint_world_x = route_x

action sentry_at(distance,span,speed,phase):
    call route_point distance
    enemies.push(
        {
            "x": route_x,
            "y": route_y,
            "z": route_z,
            "home_x": route_x,
            "home_y": route_y,
            "home_z": route_z,
            "axis_x": -sin(route_angle),
            "axis_y": cos(route_angle),
            "pipe": route_pipe,
            "angle": route_angle,
            "s": distance,
            "span": span,
            "speed": speed,
            "phase": phase,
            "model": "marble/sentry",
            "visible": true,
            "dissolve": 0
        }
    )

action spike_at(distance,across):
    call route_point distance
    hazard_x = route_x-sin(route_angle)*across
    hazard_y = route_y+cos(route_angle)*across
    call surface_at hazard_x, hazard_y
    spikes.push(
        {
            "x": hazard_x,
            "y": hazard_y,
            "z": floor_z,
            "s": distance,
            "across": across,
            "model": "marble/spikes"
        }
    )
logic.rune
@Logic/marble_run
state:
    status = "title"
    player = {"x": 3, "y": 0, "z": 10, "vx": 0, "vy": 0, "vz": 0}
    camera = {"x": -7, "y": -6, "height": 19, "angle": 31, "pitch": -36}
    avatar = {"x": 3, "y": 0, "z": 10.55, "angle": 0, "model": "marble/ball"}
    shadow = {"x": 3, "y": 0, "z": 10.02, "model": "marble/shadow"}
    stripe = {"x": 3, "y": 0, "z": 11.07, "model": "marble/stripe"}
    goal = {"x": 64, "y": 0, "z": 2, "model": "marble/beacon"}
    track = []
    surfaces = []
    scenery = []
    enemies = []
    charge_orbs = []
    fragments = []
    checkpoint = {"x": 3, "y": 0, "z": 10}
    checkpoint_active = false
    lives = 3
    level = 1
    level_count = 6
    unlocked_level = 1
    completed_levels = 0
    level_name = "01 / COPPER CASCADE"
    start_height = 10
    checkpoint_x = 36.5
    checkpoint_z = 6
    max_speed = 0.34
    gaps = []
    spikes = []
    route = []
    waypoints = []
    build_x = 0
    build_y = 0
    build_z = 10
    build_s = 0
    build_angle = 0
    route_x = 0
    route_y = 0
    route_z = 0
    route_angle = 0
    route_pipe = false
    course_s = 0
    course_angle = 0
    course_length = 0
    corner_count = 0
    pipe_count = 0
    checkpoint_y = 0
    checkpoint_world_x = 36.5
    slope_y = 0
    charges_left = 3
    charge_duration = 24
    charge_cooldown = 0
    charge_held = false
    blast_radius = 3
    kills = 0
    ticks = 0
    roll = 0
    grounded = true
    jump_held = false
    charging = false
    charge = 0
    blast_ticks = 0
    blast_power = 0
    invulnerable = 0
    floor_z = -100
    slope_x = 0
    announcement = ""
    launch_label = "Next course"
    touch_ready = false
    title_hidden = false
    ui = {"meters": [], "objective": "", "detail": "", "prompt": "", "notice": "", "panel": null}
    pause_ui = {
        "meters": [],
        "objective": "",
        "detail": "",
        "prompt": "",
        "notice": "",
        "panel": null
    }

action initialize:
    progress.cleared = clamp(floor(progress.cleared),0,level_count)
    progress.unlocked = clamp(max(floor(progress.unlocked),progress.cleared+1),1,level_count)
    level = 1
    unlocked_level = progress.unlocked
    completed_levels = 0
    selected_level = 1
    call setup_course
    call setup_title
    status = "title"
    announcement = "Marble Run"
    music.play "marble_title"
    call update_menu
    call update_view

action setup_course:
    call define_course
    player = {"x": 3, "y": 0, "z": start_height, "vx": 0, "vy": 0, "vz": 0}
    checkpoint = {"x": 3, "y": 0, "z": start_height}
    camera = {"x": -7, "y": -6, "height": start_height + 9, "angle": 31, "pitch": -36}
    lives = 3
    kills = 0
    course_s = 3
    course_segment = -1
    course_angle = 0
    ticks = 0
    roll = 0
    grounded = true
    jump_held = false
    charging = false
    charge = 0
    charge_cooldown = 0
    charge_held = false
    charges_left = 3
    blast_ticks = 0
    death_timer = 0
    death_age = 0
    death_phase = "none"
    flash = 0
    invulnerable = 0
    checkpoint_active = false
    fragments = []
    charge_orbs = []
    for i in range(0,12):
        charge_orbs.push({"x": 3, "y": 0, "z": 10.55, "model": "marble/mote", "visible": false})

action start:
    level = 1
    unlocked_level = progress.unlocked
    completed_levels = 0
    call begin_level

action begin_level:
    call setup_course
    status = "playing"
    announcement = level_name
    sound.play "marble_start"
    music.play "marble_theme"
    selected_level = level
    call update_menu
    call update_view

action advance:
    stop when status == "playing"
    if status == "level_select":
        call play_selected
        stop when true
    if status == "level_complete":
        level += 1
        unlocked_level = max(unlocked_level,level)
        call begin_level
        stop when true
    if status == "gameover":
        call begin_level
        stop when true
    call start

action return_to_title:
    music.stop
    call initialize

# Collision uses the same continuous planes as the visual wedges, not stair steps.
# The radius supports edge overhang; the ball falls once its center leaves a deck.
action surface_at(x,y):
    floor_z = -100
    slope_x = 0
    slope_y = 0
    for deck in surfaces:
        if x >= deck.min_x && x <= deck.max_x && y >= deck.min_y && y <= deck.max_y:
            along = (x-deck.x)*deck.dx+(y-deck.y)*deck.dy
            across = -(x-deck.x)*deck.dy+(y-deck.y)*deck.dx
            if along >= - 0.000001
                && along <= deck.length + 0.000001
                && abs(across) <= deck.half + 0.000001:
                candidate = deck.z+along*deck.slope
                bank_slope = 0
                if deck.pipe && abs(across) > 0.5:
                    bank = min(3,floor((abs(across)-0.5)/0.625))
                    rise = (2*bank+1)*0.125/0.625
                    candidate += bank*bank*0.125+(abs(across)-0.5-bank*0.625)*rise
                    bank_slope = (across > 0 ? 1 : -1)*rise
                if candidate > floor_z:
                    floor_z = candidate
                    slope_x = deck.dx*deck.slope-deck.dy*bank_slope
                    slope_y = deck.dy*deck.slope+deck.dx*bank_slope

# Progress follows the closest path leg, including while the marble jumps a gap.
action locate_route:
    nearest = 1000000
    from_index = course_segment-1
    to_index = course_segment+2
    best_index = course_segment
    for segment, index in route:
        if course_segment < 0 || (index >= from_index && index <= to_index):
            along = clamp((player.x-segment.x)*segment.dx+(player.y-segment.y)*segment.dy,0,segment.length)
            px = segment.x+segment.dx*along
            py = segment.y+segment.dy*along
            distance = (player.x-px)*(player.x-px)+(player.y-py)*(player.y-py)
            if distance < nearest:
                nearest = distance
                best_index = index
                course_s = segment.s+along
                course_angle = segment.angle
    course_segment = best_index

action tick(input):
    if status == "title" || status == "level_select":
        call tick_menu input
        call update_view
        stop when true
    stop when status != "playing"
    if death_timer > 0:
        call tick_death input
        stop when true
    ticks += 1
    invulnerable = max(0, invulnerable-1)
    blast_ticks = max(0, blast_ticks-1)
    charge_cooldown = max(0,charge_cooldown-1)
    call surface_at player.x, player.y
    grounded = floor_z > -50 && abs(player.z-floor_z) < 0.04 && player.vz <= 0
    forward = clamp((input.forward ? 1 : 0)-(input.back ? 1 : 0)+(input.move_y ? input.move_y : 0),-1,1)
    side =
        clamp((input.right ? 1: 0) - (input.left ? 1: 0) + (input.move_x ? input.move_x: 0), -1, 1)
    magnitude = max(1,sqrt(forward*forward+side*side))
    # Camera-relative steering with diagonal normalization and downhill gravity.
    ax = (cos(31)*forward-sin(31)*side)/magnitude
    ay = (sin(31)*forward+cos(31)*side)/magnitude
    # A press commits one cell to the entire wind-up. Early release cannot fire,
    # and holding the button after discharge cannot queue another charge.
    if !!input.charge
        && !charge_held
        && grounded
        && !charging
        && charges_left > 0
        && charge_cooldown == 0:
        charging = true
        charge = 0
        charges_left -= 1
        sound.play "marble_charge"
    charge_held = !!input.charge
    anchored = charging
    if anchored:
        charge = min(charge_duration,charge+1)
        player.vx = 0
        player.vy = 0
        player.vz = 0
        if charge == charge_duration:
            call blast
            charging = false
            charge = 0
            charge_cooldown = 90
    if !anchored:
        player.vx = clamp(player.vx*0.975+ax*0.017-(grounded ? slope_x*0.035 : 0),-max_speed,max_speed)
        player.vy = clamp(player.vy*0.975+ay*0.017-(grounded ? slope_y*0.035 : 0),-max_speed,max_speed)
        velocity = sqrt(player.vx*player.vx+player.vy*player.vy)
        if velocity > max_speed:
            player.vx = player.vx/velocity*max_speed
            player.vy = player.vy/velocity*max_speed
        if !!input.jump && !jump_held && grounded:
            player.vz = 0.34
            grounded = false
            sound.play "marble_jump"
        old_z = player.z
        # Substeps keep edge crossings and landings stable at maximum speed.
        for substep in range(0,4):
            launch_vz = slope_x*player.vx+slope_y*player.vy
            previous_x = player.x
            previous_y = player.y
            player.x += player.vx/4
            player.y += player.vy/4
            call surface_at player.x, player.y
            if grounded && floor_z > player.z+0.18:
                player.x = previous_x
                player.y = previous_y
                player.vx = 0
                player.vy = 0
                call surface_at player.x, player.y
            follows_surface = grounded && floor_z > -50 && abs(player.z-floor_z) < 0.15
            if follows_surface:
                player.z = floor_z
            if !follows_surface:
                if grounded && floor_z < -50:
                    player.vz = clamp(launch_vz,-0.4,0.5)
                grounded = false
                player.z += player.vz/4
                if player.vz <= 0
                    && floor_z > - 50
                    && player.z <= floor_z
                    && old_z >= floor_z - 0.15:
                    player.z = floor_z
                    player.vz = 0
                    grounded = true
            old_z = player.z
        if !grounded:
            player.vz = max(-0.7,player.vz-0.028)
        roll += sqrt(player.vx*player.vx+player.vy*player.vy)*100
    jump_held = !!input.jump
    for post in scenery:
        dx = player.x-post.x
        dy = player.y-post.y
        distance = sqrt(dx*dx+dy*dy)
        if distance < 0.95 && abs(player.z-post.z) < 1.2:
            if distance < 0.01:
                dx = -1
                distance = 1
            player.x = post.x+dx/distance*0.96
            player.y = post.y+dy/distance*0.96
            player.vx = dx/distance*0.16
            player.vy = dy/distance*0.16
    for enemy in enemies:
        if enemy.dissolve > 0:
            enemy.dissolve = min(1,enemy.dissolve+0.08)
            enemy.visible = enemy.dissolve < 1
        if enemy.dissolve == 0:
            offset = sin(ticks*enemy.speed+enemy.phase)*enemy.span
            enemy.x = enemy.home_x+enemy.axis_x*offset
            enemy.y = enemy.home_y+enemy.axis_y*offset
            enemy.z = enemy.home_z
            if enemy.pipe && abs(offset) > 0.5:
                bank = min(3,floor((abs(offset)-0.5)/0.625))
                enemy.z+=
                    bank * bank * 0.125 + (abs(offset) - 0.5 - bank * 0.625) * (2 * bank + 1) * 0.2
            if abs(player.x - enemy.x) < 0.9
                && abs(player.y - enemy.y) < 0.9
                && abs(player.z - enemy.z) < 1
                && invulnerable == 0:
                call lose_life
    for spike in spikes:
        dx = player.x-spike.x
        dy = player.y-spike.y
        if dx * dx + dy * dy < 0.85 * 0.85
            && player.z < spike.z + 0.7
            && player.z + 1.1 > spike.z
            && invulnerable == 0:
            call lose_life
    if death_timer > 0:
        call update_view
        stop when true
    call locate_route
    if course_s > checkpoint_x - 0.5
        && course_s < checkpoint_x + 5
        && grounded
        && !checkpoint_active:
        checkpoint = {"x": checkpoint_world_x, "y": checkpoint_y, "z": checkpoint_z}
        checkpoint_active = true
        announcement = "Checkpoint saved"
        sound.play "marble_checkpoint"
    if player.z < 0.8:
        call lose_life
    if death_timer > 0:
        call update_view
        stop when true
    goal_distance =
        (player.x - goal.x) * (player.x - goal.x) + (player.y - goal.y) * (player.y - goal.y)
    if status == "playing" && goal_distance < 1.5*1.5 && abs(player.z-goal.z) < 0.1 && grounded:
        completed_levels = level
        progress.cleared = max(progress.cleared,level)
        progress.unlocked = max(progress.unlocked,min(level_count,level+1))
        unlocked_level = progress.unlocked
        call update_menu
        status = level < level_count ? "level_complete" : "won"
        announcement = status == "won" ? "All courses cleared" : "Course clear"
        music.stop
        sound.play "marble_win"
    call update_effects
    call update_view

action blast:
    stop when !charging || charge < charge_duration
    blast_power = 1
    blast_ticks = 18
    radius = blast_radius
    sound.play "marble_blast"
    for enemy in enemies:
        distance = sqrt((enemy.x-player.x)*(enemy.x-player.x)+(enemy.y-player.y)*(enemy.y-player.y)+(enemy.z-player.z)*(enemy.z-player.z))
        if enemy.visible && enemy.dissolve == 0 && distance < radius:
            enemy.dissolve = 0.01
            kills += 1
            for i in range(0,10):
                angle = i*36
                fragments.push(
                    {
                        "x": enemy.x,
                        "y": enemy.y,
                        "z": enemy.z + 0.7,
                        "vx": cos(angle) * 0.16,
                        "vy": sin(angle) * 0.16,
                        "vz": 0.12 + i * 0.012,
                        "life": 28,
                        "life_max": 28,
                        "model": "marble/shard",
                        "scale": 0.8 + i * 0.035,
                        "visible": true
                    }
                )

action lose_life:
    stop when status != "playing" || death_timer > 0
    lives = max(0,lives-1)
    death_timer = 36
    death_age = 0
    death_phase = "shatter"
    flash = 0.18
    invulnerable = 75
    player.vx = 0
    player.vy = 0
    player.vz = 0
    charge = 0
    charging = false
    blast_ticks = 0
    announcement = lives > 0 ? "Marble lost. Lives left: "+lives : "Game over"
    sound.play "marble_shatter"
    for i in range(0,24):
        angle = i*137.5
        fragments.push(
            {
                "x": player.x,
                "y": player.y,
                "z": max(0.8, player.z) + 0.55,
                "vx": cos(angle) * (0.08 + i * 0.004),
                "vy": sin(angle) * (0.08 + i * 0.004),
                "vz": 0.12 + (i % 5) * 0.04,
                "life": 36,
                "life_max": 36,
                "model": i % 2 == 0 ? "marble/death_shard": "marble/death_glint",
                "scale": 0.6 + (i % 4) * 0.15,
                "visible": true
            }
        )

action tick_death(input):
    ticks += 1
    death_age += 1
    death_timer -= 1
    flash = max(0,0.18-death_age*0.012)
    jump_held = !!input.jump
    charge_held = !!input.charge
    call update_effects
    if death_timer == 0:
        death_phase = "none"
        fragments = []
        if lives > 0:
            player = {
                "x": checkpoint.x,
                "y": checkpoint.y,
                "z": checkpoint.z,
                "vx": 0,
                "vy": 0,
                "vz": 0
            }
            grounded = true
            course_segment = -1
            invulnerable = 75
        if lives == 0:
            status = "gameover"
            music.stop
    call update_view

action update_effects:
    for i in range(0,12):
        orb = charge_orbs[i]
        orb.visible = charging || blast_ticks > 0
        angle = ticks*6+i*30
        radius = charging
            ? 0.7 + charge / charge_duration * 0.6
            : (18 - blast_ticks) * blast_radius / 18
        orb.x = player.x+cos(angle)*radius
        orb.y = player.y+sin(angle)*radius
        orb.z = player.z+0.55+sin(angle*2)*0.15
        orb.scale = charging ? 0.5+charge/charge_duration : max(0.1,blast_ticks/12)
    # Bounded effect lifetime avoids accumulating invisible objects on long runs.
    alive = []
    for shard in fragments:
        shard.x += shard.vx
        shard.y += shard.vy
        shard.z += shard.vz
        shard.vz -= 0.025
        shard.life -= 1
        shard.dissolve = clamp(1-shard.life/shard.life_max,0,1)
        if shard.life > 0:
            alive.push(shard)
    fragments = alive

action update_view:
    avatar.x = player.x
    avatar.y = player.y
    avatar.z = player.z+0.55
    avatar.angle = roll
    avatar.visible = death_timer > 0
        ? death_age < 24
        : (lives > 0 && (invulnerable == 0 || ticks % 6 < 3))
    avatar.dissolve = death_timer > 0 ? min(1,death_age/20) : 0
    avatar.scale = death_timer > 0 ? 1+min(death_age,8)*0.025 : 1
    stripe.x = player.x+sin(roll)*0.53
    stripe.y = player.y
    stripe.z = player.z+0.55+cos(roll)*0.53
    call surface_at player.x, player.y
    shadow.x = player.x
    shadow.y = player.y
    shadow.z = floor_z+0.02
    shadow.visible = floor_z > 0
    stripe.visible = avatar.visible
    stripe.dissolve = avatar.dissolve
    camera.x = player.x-10
    camera.y = player.y-6
    camera.height = max(8,player.z+9)
    touch_ready = status == "playing" && death_timer == 0
    title_hidden = status == "playing"
    pause_hidden = status != "playing"
    title_actions_hidden = status != "title"
    selector_hidden = status != "level_select"
    selector_unavailable = status == "playing"
    launch_hidden = status == "title" || status == "level_select" || status == "playing"
    launch_label = status == "level_complete"
        ? "Next course"
        : (status == "gameover" ? "Retry": "Play again")
    ui = {
        "style": "floating",
        "meters": [
            {
                "label": "",
                "icon": "marble/hud/marble_full",
                "emptyIcon": "marble/hud/marble_empty",
                "display": "pips",
                "value": lives,
                "max": 3,
                "color": 6873576
            },
            {
                "label": "",
                "showValue": false,
                "icon": charging ? "marble/hud/bolt_charge": (charges_left == 0 ? "marble/hud/bolt_empty": (charge_cooldown > 0 ? "marble/hud/hourglass": "marble/hud/bolt_ready")),
                "value": charging ? floor(charge * 100 / charge_duration): (charges_left == 0 ? 0: (charge_cooldown > 0 ? floor((90 - charge_cooldown) * 100 / 90): 100)),
                "max": 100,
                "color": charging ? 16242315: (charges_left == 0 ? 6783885: 6873576),
                "display": "bar"
            },
            {
                "label": "",
                "icon": "marble/hud/cell_full",
                "emptyIcon": "marble/hud/cell_empty",
                "display": "pips",
                "value": charges_left,
                "max": 3,
                "color": 16242315
            }
        ],
        "objective": "",
        "detail": "",
        "prompt": "",
        "notice": "",
        "panel": null
    }
    if !launch_hidden:
        ui.meters = []
        ui.heading = announcement
        ui.prompt = "ENTER / "+launch_label
    pause_ui = {
        "meters": [],
        "objective": "ARROWS STEER / SPACE JUMP / X BLAST",
        "detail": level_name,
        "prompt": "P RESUME / T TITLE",
        "notice": "",
        "panel": null
    }

    if status == "level_select":
        ui = {
            "meters": [],
            "objective": "",
            "detail": "",
            "prompt": "",
            "notice": "",
            "panel": {
                "title": "COURSE " + selected_level + " / " + level_count,
                "body": selection_description,
                "choices": [
                    "< PREVIOUS",
                    selection_name + (selection_locked ? " / LOCKED": " / READY"),
                    "NEXT >"
                ],
                "selected": 1,
                "footer": "LEFT / RIGHT / ENTER"
            }
        }
menus.rune
@Logic/marble_run
state:
    progress = {"unlocked": 1, "cleared": 0}
    course_segment = -1
    death_timer = 0
    death_age = 0
    death_phase = "none"
    flash = 0
    title_props = []
    menu_ticks = 0
    menu_nav_held = false
    menu_confirm_held = false
    title_actions_hidden = false
    selector_hidden = true
    selector_unavailable = false
    launch_hidden = true
    pause_hidden = true
    selected_level = 1
    selection_name = "COPPER CASCADE"
    selection_description = ""
    selection_locked = false
    course_cards = []
    course_names = [
        "COPPER CASCADE",
        "GLASS SPINE",
        "TEMPEST RIDGE",
        "AURORA SWITCHBACK",
        "EMBER FOUNDRY",
        "CELESTIAL CROWN"
    ]
    course_descriptions = [
        "Learn the charge, first corner and blue banks.",
        "Narrow blue ramps, bank spikes and a zigzag.",
        "Return legs, trough hazards and three gaps.",
        "Reverse direction through four aurora bends.",
        "Four jumps and a furnace of spike rows.",
        "Five gaps, seven sentries and the final crown."
    ]

action setup_title:
    menu_ticks = 0
    menu_nav_held = false
    menu_confirm_held = false
    title_props = [
        {"x": 10, "y": 8, "z": 1.2, "model": "marble/corner", "scale": 0.7},
        {"x": 10, "y": 8, "z": 3, "model": "marble/ball", "scale": 3},
        {"x": 10, "y": 8, "z": 4.65, "model": "marble/stripe", "scale": 2}
    ]
    for i in range(0,8):
        title_props.push(
            {
                "x": 10 + cos(i * 45) * 3,
                "y": 8 + sin(i * 45) * 3,
                "z": 2.8,
                "model": "marble/mote",
                "scale": 2
            }
        )

action open_selector:
    stop when status == "playing"
    selected_level = level
    status = "level_select"
    menu_nav_held = false
    menu_confirm_held = false
    music.play "marble_title"
    call update_menu
    call update_view

action select_course(number):
    stop when status != "level_select"
    selected_level = clamp(floor(number),1,level_count)
    sound.play "marble_menu"
    call update_menu
    call update_view

action play_selected:
    stop when status != "level_select" || selected_level > progress.unlocked
    level = selected_level
    unlocked_level = progress.unlocked
    completed_levels = level-1
    call begin_level

action tick_menu(input):
    menu_ticks += 1
    title_props[1].angle = menu_ticks*2
    title_props[1].z = 3+sin(menu_ticks*2)*0.15
    title_props[2].x = 10+sin(menu_ticks*2)*1.5
    title_props[2].z = 3+cos(menu_ticks*2)*1.5
    if status == "level_select":
        direction = (input.right || input.back ? 1 : 0)-(input.left || input.forward ? 1 : 0)+(input.move_x ? input.move_x : 0)-(input.move_y ? input.move_y : 0)
        if abs(direction) > 0.5 && !menu_nav_held:
            call select_course selected_level+(direction > 0 ? 1 : -1)
        menu_nav_held = abs(direction) > 0.5
    if !!input.jump && !menu_confirm_held:
        call advance
    menu_confirm_held = !!input.jump

action update_menu:
    selected_level = clamp(selected_level,1,level_count)
    selection_name = course_names[selected_level-1]
    selection_description = course_descriptions[selected_level-1]
    selection_locked = selected_level > progress.unlocked
    course_cards = []
    for number in range(1,level_count+1):
        label = "0"+number+" / "+course_names[number-1]
        label+=number > progress.unlocked
            ? " / LOCKED"
            : (number <= progress.cleared ? " / CLEAR": " / READY")
        course_cards.push({"label": label, "selected": number == selected_level})
models.rune
@Palette/marble
colors = {
    "b": "#277eab",
    "c": "#68e1e8",
    "d": "#5f3157",
    "g": "#f7d68b",
    "o": "#d59968",
    "p": "#ba5871",
    "s": "#344f61",
    "t": "#668b87",
    "w": "#e5fbdf"
}

@Model/marble/ball
palette = marble
unit = 1
shapes:
    {"type":"sphere","center":[0,0,0],"radius":0.55,"color":"c"}

@Model/marble/stripe
palette = marble
unit = 1
shapes:
    {"type":"sphere","center":[0,0,0],"radius":0.13,"color":"w"}

@Model/marble/mote
palette = marble
unit = 1
shapes:
    {"type":"sphere","center":[0,0,0],"radius":0.09,"color":"g"}

@Model/marble/shard
palette = marble
unit = 0.125
blocks:
    {"from":[-1,-1,-1],"size":[2,2,2],"color":"p"}

@Model/marble/deck
palette = marble
unit = 1
blocks:
    {"from":[0,-3,-1],"size":[8,6,1],"color":"t"}

@Model/marble/landing
palette = marble
unit = 1
blocks:
    {"from":[0,-4,-1],"size":[8,8,1],"color":"t"}

# A wedge rises along local +X. Rotating it 180 degrees makes a downhill run.
@Model/marble/slope
palette = marble
unit = 1
shapes:
    {"type":"ramp","from":[0,-3,0],"size":[16,6,4],"color":"o"}
blocks:
    {"from":[0,-3,-1],"size":[16,6,1],"color":"s"}

@Model/marble/wide_slope
palette = marble
unit = 1
shapes:
    {"type":"ramp","from":[0,-4,0],"size":[16,8,4],"color":"o"}
blocks:
    {"from":[0,-4,-1],"size":[16,8,1],"color":"s"}

@Model/marble/sentry
palette = marble
unit = 1
shapes:
    {"type":"cylinder","center":[0,0,0.38],"radius":0.55,"height":0.76,"color":"d"}
    {"type":"sphere","center":[0,0,0.8],"radius":0.48,"color":"p"}
    {"type":"sphere","center":[-0.42,0,0.88],"radius":0.16,"color":"g"}

@Model/marble/pillar
palette = marble
unit = 1
shapes:
    {"type":"cylinder","center":[0,0,0.6],"radius":0.4,"height":1.2,"color":"s"}
    {"type":"cylinder","center":[0,0,1.22],"radius":0.48,"height":0.12,"color":"g"}

@Model/marble/beacon
palette = marble
unit = 1
shapes:
    {"type":"cylinder","center":[0,0,0.12],"radius":1.5,"height":0.24,"color":"g"}
    {"type":"cylinder","center":[0,0,1],"radius":0.12,"height":2,"color":"c"}
    {"type":"sphere","center":[0,0,2.2],"radius":0.5,"color":"w"}

@Model/marble/shadow
palette = marble
unit = 1
shapes:
    {"type":"cylinder","center":[0,0,0],"radius":0.6,"height":0.03,"color":"s"}

@Model/marble/deck_glass
palette = marble
unit = 0.25
blocks:
    {"from":[0,-9,-4],"size":[32,18,4],"color":"t"}

@Model/marble/deck_spine
palette = marble
unit = 0.25
blocks:
    {"from":[0,-7,-4],"size":[32,14,4],"color":"t"}

@Model/marble/deck_finish
palette = marble
unit = 0.25
blocks:
    {"from":[0,-10,-4],"size":[32,20,4],"color":"t"}

@Model/marble/deck_ridge
palette = marble
unit = 0.25
blocks:
    {"from":[0,-8,-4],"size":[32,16,4],"color":"t"}

@Model/marble/deck_storm
palette = marble
unit = 0.25
blocks:
    {"from":[0,-6,-4],"size":[32,12,4],"color":"t"}

@Model/marble/slope_glass
palette = marble
unit = 1
shapes:
    {"type":"ramp","from":[0,-2.25,0],"size":[16,4.5,4],"color":"b"}

@Model/marble/slope_spine
palette = marble
unit = 1
shapes:
    {"type":"ramp","from":[0,-1.75,0],"size":[16,3.5,4],"color":"b"}

@Model/marble/slope_storm
palette = marble
unit = 1
shapes:
    {"type":"ramp","from":[0,-1.5,0],"size":[16,3.0,4],"color":"p"}

@Model/marble/corner
palette = marble
unit = 0.25
blocks:
    {"from":[-16,-16,-4],"size":[32,32,4],"color":"t"}

@Model/marble/arrow
palette = marble
unit = 0.125
blocks:
    {"from":[-7,-1,0],"size":[10,2,1],"color":"g"}
    {"from":[2,-4,0],"size":[2,8,1],"color":"g"}
    {"from":[4,-3,0],"size":[2,6,1],"color":"g"}
    {"from":[6,-1,0],"size":[2,2,1],"color":"g"}

@Model/marble/spikes
palette = marble
unit = 0.125
blocks:
    {"from":[-5,-5,-1],"size":[10,10,1],"color":"g"}
    {"from":[-4,-4,0],"size":[8,8,1],"color":"p"}
    {"from":[-3,-3,1],"size":[6,6,1],"color":"p"}
    {"from":[-2,-2,2],"size":[4,4,1],"color":"w"}
    {"from":[-1,-1,3],"size":[2,2,2],"color":"w"}

@Model/marble/pipe_bank_0
palette = marble
unit = 0.125
shapes:
    {"type":"ramp","from":[0,-16,0],"size":[5,32,1],"color":"b"}

@Model/marble/pipe_bank_1
palette = marble
unit = 0.125
shapes:
    {"type":"ramp","from":[0,-16,0],"size":[5,32,3],"color":"b"}
blocks:
    {"from":[0,-16,-1],"size":[5,32,1],"color":"s"}

@Model/marble/pipe_bank_2
palette = marble
unit = 0.125
shapes:
    {"type":"ramp","from":[0,-16,0],"size":[5,32,5],"color":"b"}
blocks:
    {"from":[0,-16,-4],"size":[5,32,4],"color":"s"}

@Model/marble/pipe_bank_3
palette = marble
unit = 0.125
shapes:
    {"type":"ramp","from":[0,-16,0],"size":[5,32,7],"color":"b"}
blocks:
    {"from":[0,-16,-9],"size":[5,32,9],"color":"s"}

@Model/marble/death_shard
palette = marble
unit = 0.125
blocks:
    {"from":[-1,-1,-1],"size":[2,2,2],"color":"c"}

@Model/marble/death_glint
palette = marble
unit = 0.125
blocks:
    {"from":[-1,-1,-1],"size":[2,2,2],"color":"w"}
shell.rune
@Page/marble_cabinet
title = Marble Run - Six Descents
logic = marble_cabinet
style = marble_cabinet
view:
    main .cabinet:
        p .rotate-to-play:
            span aria-hidden=true "↻"
            span "Rotate your phone to play in landscape."
        section .game-card:
            div .toolbar:
                details .toolbar-settings open=true:
                    summary "Game options"
                    div .display-options:
                        label:
                            span "Resolution"
                            select data-pixel-resolution=true:
                                option value="384x240" "384 × 240"
                                option value="576x360" selected=true "576 × 360"
                                option value="768x480" "768 × 480"
                        label:
                            span "Palette"
                            select data-pixel-palette=true:
                                option value=original "Original"
                                option value="09120c,39533a,78944f,b9ce77,e7edaf" data-pixel-outline=true selected=true "Pocket"
                                option value="26160d,4e2616,784421,a86931,d39745,f0c87a,fff1ba" "Amber"
                                option value="151325,2f314f,535675,7b8aad,adcbd3,eff5cf" "Moonlight"
                        label:
                            span "Frame rate"
                            select data-pixel-frame-rate=true:
                                option value=simulation "30 FPS"
                                option value=60 "60 FPS"
                                option value=display "Uncapped (display)"
                        label:
                            input type=checkbox data-pixel-gpu=true title="Experimental WebGL 2 renderer"
                            span "GPU"
                        span .fps data-pixel-fps=true title="Frames drawn per second" "CPU · — FPS"
                    div .buttons:
                        button data-pixel-pause=true data-pixel-hidden=pause_hidden "Pause / P"
                        button data-pixel-mute=true "Sound"
                button data-pixel-fullscreen=true "Fullscreen"
            div .game-surface:
                canvas data-rune-pixel-3d=true tabindex=0 autofocus=true aria-label="Marble Run. Arrows steer, Space jumps, X charges a blast."
                div .pause-menu data-pixel-paused=true data-pixel-menu=true hidden=true:
                    h2 "Paused"
                    button data-pixel-pause=true "Resume / P"
                    button data-pixel-restart=true "Return to title / T"
                    button .fullscreen-exit data-pixel-fullscreen=true "Exit fullscreen"
                div .title-actions data-pixel-hidden=title_actions_hidden:
                    button .primary data-pixel-start=true "Start"
                    button data-pixel-action="open_selector" "Levels"
                    button .fullscreen-exit data-pixel-fullscreen=true "Exit fullscreen"
                section .level-picker data-pixel-hidden=selector_hidden hidden=true aria-label="Level selector":
                    div .picker-heading:
                        h2 "Choose a course"
                        button data-pixel-action="return_to_title" "Title / T"
                    div .course-grid:
                        button .course-card data-pixel-action="select_course" data-pixel-args="[1]" data-pixel-text=course_cards.0.label data-pixel-selected=course_cards.0.selected "Course 1"
                        button .course-card data-pixel-action="select_course" data-pixel-args="[2]" data-pixel-text=course_cards.1.label data-pixel-selected=course_cards.1.selected "Course 2"
                        button .course-card data-pixel-action="select_course" data-pixel-args="[3]" data-pixel-text=course_cards.2.label data-pixel-selected=course_cards.2.selected "Course 3"
                        button .course-card data-pixel-action="select_course" data-pixel-args="[4]" data-pixel-text=course_cards.3.label data-pixel-selected=course_cards.3.selected "Course 4"
                        button .course-card data-pixel-action="select_course" data-pixel-args="[5]" data-pixel-text=course_cards.4.label data-pixel-selected=course_cards.4.selected "Course 5"
                        button .course-card data-pixel-action="select_course" data-pixel-args="[6]" data-pixel-text=course_cards.5.label data-pixel-selected=course_cards.5.selected "Course 6"
                    p .course-description data-pixel-text=selection_description "Pick a course."
                    div .picker-footer:
                        button data-pixel-action="select_course" data-pixel-args="[1]" "First course"
                        button .primary data-pixel-action="play_selected" data-pixel-disabled=selection_locked "Play selected / Enter"
                        button .fullscreen-exit data-pixel-fullscreen=true "Exit fullscreen"
            div .launch data-pixel-hidden=launch_hidden:
                button .primary data-pixel-action="advance" data-pixel-text=launch_label "Next course"
            p .announcement data-pixel-text=announcement role=status aria-live=polite "Marble Run"
        details .guide:
            summary "How to play"
            p "Steer with the arrows or WASD. Follow the gold arrows through corners and ride the blue banks. Gold posts mark gaps. Jump over gaps and spikes with Space."
            p "Press X or Shift to spend a cell. The marble stops and blasts automatically when the bolt gauge fills. An hourglass shows the cooldown. You get three cells per course."
            p "On a controller, use the left stick to steer, the bottom face button to jump, and the left face button or right trigger to blast. On touchscreens, use the on-screen stick and buttons; tap the pause button in the top-right corner. Use the pause menu to leave fullscreen."

@Logic/marble_cabinet
state:
    label = "Marble Run"

@Style/marble_cabinet
rules:
    :root:
        color-scheme = light
    *:
        box-sizing = border-box
    body:
        margin = 0
        background = #eef0e4
        color = #173b46
        font-family = system-ui, sans-serif
    .cabinet:
        max-width = 1120px
        margin = auto
        padding = clamp(16px, 3vw, 40px)
    .game-card:
        overflow = hidden
        background = #173b46
        border = 4px solid #173b46
        border-radius = 16px
        box-shadow = 0 12px 0 #d8ddcb
    .toolbar:
        display = flex
        align-items = center
        justify-content = space-between
        flex-wrap = wrap
        gap = 8px
        padding = 8px
    .display-options:
        display = flex
        flex-wrap = wrap
        gap = 8px 14px
    .toolbar-settings summary:
        display = none
        cursor = pointer
        padding = 12px
        color = #fff4d6
        font-size = 12px
        font-weight = 700
    .toolbar-settings:not([open]) summary:
        display = block
    .display-options label:
        display = flex
        align-items = center
        gap = 6px
        color = #fff4d6
        font-size = 12px
        font-weight = 700
    .display-options select:
        min-height = 44px
        padding = 6px
        border = 1px solid #718195
        border-radius = 6px
        background = #344e6b
        color = #fff4d6
        font = inherit
    .display-options input:
        margin = 0
        width = 17px
        height = 17px
        accent-color = #ffe18a
    .fps:
        align-self = center
        color = #fff4d6
        font-size = 12px
        font-weight = 700
        font-variant-numeric = tabular-nums
        min-width = 90px
    .buttons:
        display = flex
        flex-wrap = wrap
        gap = 6px
    button:
        cursor = pointer
        border = 1px solid #718195
        border-radius = 6px
        background = #344e6b
        color = #fff4d6
        padding = 10px 12px
        min-height = 44px
        font = inherit
        font-size = 12px
        font-weight = 700
    button:hover:
        background = #45617f
    button:focus-visible, select:focus-visible:
        outline = 3px solid #ffe18a
        outline-offset = 3px
    .game-surface:
        position = relative
        background = #427cc4
    .rotate-to-play:
        display = none
    .fullscreen-exit:
        display = none
    .game-surface:fullscreen .fullscreen-exit, .game-surface.rune-pixel3d-expanded .fullscreen-exit:
        display = inline-block
    canvas:
        position = relative
        display = block
        width = 100%
        height = auto
        aspect-ratio = 8 / 5
        image-rendering = pixelated
        touch-action = none
        outline-offset = -3px
    .launch:
        display = flex
        align-items = center
        justify-content = center
        flex-wrap = wrap
        gap = 8px 20px
        padding = 16px
        color = #d2dedf
        font-size = 13px
    .primary:
        background = #ffe18a
        border-color = #ffe18a
        color = #173b46
        padding = 14px 24px
        font-size = 14px
    .primary:hover:
        background = #fff4d6
    .announcement:
        position = absolute
        width = 1px
        height = 1px
        overflow = hidden
        clip-path = inset(50%)
    .guide:
        max-width = 640px
        margin-top = 24px
    .guide summary:
        cursor = pointer
        font-size = 14px
        font-weight = 700
    .guide p:
        font-size = 13px
        line-height = 1.7
        color = #546b6f
    .pause-menu:
        position = absolute
        inset = 0
        display = flex
        flex-direction = column
        justify-content = center
        align-items = center
        gap = 12px
        padding = 20px
        background = #173b46ed
        color = #fff4d6
    .pause-menu h2:
        margin = 0
    [hidden]:
        display = none !important

    .title-actions:
        position = absolute
        bottom = clamp(36px, 5.4vw, 64px)
        left = 16px
        right = 16px
        display = flex
        flex-wrap = wrap
        gap = 10px
        justify-content = center
    .level-picker:
        position = absolute
        inset = 0
        overflow = auto
        background = #102a40
        color = #fff4d6
        padding = clamp(12px, 3vw, 28px)
        display = flex
        flex-direction = column
        justify-content = flex-start
        gap = 14px
    .picker-heading:
        display = flex
        justify-content = space-between
        align-items = center
        gap = 12px
    .picker-heading h2:
        margin = 0
        font-size = clamp(18px, 3vw, 32px)
        letter-spacing = 1px
    .course-grid:
        display = grid
        grid-template-columns = repeat(3, minmax(0, 1fr))
        gap = 10px
    .course-card:
        min-height = clamp(52px, 8vw, 88px)
        text-align = left
        line-height = 1.7
        background = #214554
        border-color = #537973
        font-size = clamp(9px, 1.2vw, 13px)
    .course-card[aria-pressed="true"]:
        background = #315b63
        border-color = #ffe18a
        box-shadow = inset 0 0 0 2px #ffe18a
    .course-description:
        margin = 0
        color = #b5d5ce
        min-height = 22px
        font-size = 13px
    .picker-footer:
        display = flex
        justify-content = space-between
        align-items = center
        gap = 12px
    button:disabled:
        cursor = not-allowed
        opacity = 0.45

    .game-surface:has(.level-picker:not([hidden])):
        min-height = 340px

responsive:
    (pointer: coarse) and (orientation: portrait):
        html[data-game-rotation] body:not(.rune-embedded-game) .rotate-to-play:
            display = flex
            align-items = center
            gap = 8px
            color = #173b46
            font-size = 13px
        .rotate-to-play span:first-child:
            font-size = 24px
    (max-width: 480px):
        .course-grid:
            grid-template-columns = repeat(2, minmax(0, 1fr))
            gap = 8px
        .course-card:
            font-size = 12px
        .picker-footer:
            flex-wrap = wrap
    (pointer: coarse) and (max-width: 480px):
        .toolbar-settings summary:
            display = block
        .game-surface:not(:fullscreen):not(.rune-pixel3d-expanded):has(.rune-control-touch:not([hidden])):
            padding-bottom = 112px
        .game-surface:not(:fullscreen):not(.rune-pixel3d-expanded) .rune-control-touch:
            top = calc(100% - 112px) !important
            height = 112px !important
sound.rune
@Sound/marble_jump
wave = triangle
sequence = C4:40ms, G4:40ms, C5:60ms
volume = 0.1

@Sound/marble_charge
wave = sine
sequence = C4:120ms, E4:120ms, G4:120ms, C5:120ms, E5:120ms, G5:120ms, C6:80ms
volume = 0.09

@Sound/marble_blast
wave = noise
sequence = G3:50ms, C3:70ms, G2:100ms
volume = 0.12

@Sound/marble_hurt
wave = triangle
sequence = E4:70ms, C4:70ms, G3:100ms
volume = 0.12

@Sound/marble_checkpoint
wave = sine
sequence = C5:80ms, E5:80ms, G5:140ms
volume = 0.12

@Sound/marble_win
wave = triangle
sequence = C5:100ms, E5:100ms, G5:100ms, C6:250ms
volume = 0.13

# Original 56-bar song form, approximately 1:47 at 126 BPM before looping.
@Music/marble_theme
type = synth
tempo = 126
time_signature = 4/4
loop = true
volume = 0.055
instruments = {"lead":"pluck","harmony":"strings","arp":"bell","bass":"triangle","drums":"drums"}
sections = {
    "breakdown": {
        "arp": "C4:8 E4:8 G4:8 C5:8 G4:8 E4:8 G4:8 E4:8 | A3:8 C4:8 E4:8 A4:8 E4:8 C4:8 E4:8 C4:8 | F3:8 A3:8 C4:8 F4:8 C4:8 A3:8 C4:8 A3:8 | G3:8 B3:8 D4:8 G4:8 D4:8 B3:8 D4:8 B3:8",
        "bars": 4,
        "bass": "C3:2 G3:2 | A2:2 E3:2 | F2:2 C3:2 | G2:2 D3:2",
        "harmony": "[C4,E4,G4]:1 | [A3,C4,E4]:1 | [F3,A3,C4]:1 | [G3,B3,D4]:1",
        "lead": "C5:1 | A4:2 E5:2 | F5:2 C5:2 | D5:4 B4:4 G4:2"
    },
    "bridge": {
        "arp": "A3:8 C4:8 E4:8 A4:8 E4:8 C4:8 E4:8 C4:8 | F3:8 A3:8 C4:8 F4:8 C4:8 A3:8 C4:8 A3:8 | G3:8 B3:8 D4:8 G4:8 D4:8 B3:8 D4:8 B3:8 | C4:8 E4:8 G4:8 C5:8 G4:8 E4:8 G4:8 E4:8 | A3:8 C4:8 E4:8 A4:8 E4:8 C4:8 E4:8 C4:8 | F3:8 A3:8 C4:8 F4:8 C4:8 A3:8 C4:8 A3:8 | G3:8 B3:8 D4:8 G4:8 D4:8 B3:8 D4:8 B3:8 | C4:8 E4:8 G4:8 C5:8 G4:8 E4:8 G4:8 E4:8",
        "bars": 8,
        "bass": "A2:4 E3:4 A2:4 E3:4 | F2:4 C3:4 F2:4 C3:4 | G2:4 D3:4 G2:4 D3:4 | C3:4 G3:4 C3:4 G3:4 | A2:4 E3:4 A2:4 E3:4 | F2:4 C3:4 F2:4 C3:4 | G2:4 D3:4 G2:4 D3:4 | C3:4 G3:4 C3:4 G3:4",
        "drums": "kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:8 snare:8 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:8 snare:8 hihat:4",
        "harmony": "[A3,C4,E4]:1 | [F3,A3,C4]:1 | [G3,B3,D4]:1 | [C4,E4,G4]:1 | [A3,C4,E4]:1 | [F3,A3,C4]:1 | [G3,B3,D4]:1 | [C4,E4,G4]:1",
        "lead": "E5:4 A5:4 C6:4 B5:4 | A5:8 G5:8 F5:4 E5:4 C5:4 | D5:8 F5:8 A5:4 G5:4 F5:4 | E5:4 B4:4 E5:2 | A4:8 C5:8 E5:4 A5:2 | G5:4 F5:4 E5:4 C5:4 | D5:4 F5:8 A5:8 C6:4 A5:4 | B5:4 G5:4 D5:2"
    },
    "chorus": {
        "arp": "C4:8 E4:8 G4:8 C5:8 G4:8 E4:8 G4:8 E4:8 | A3:8 C4:8 E4:8 A4:8 E4:8 C4:8 E4:8 C4:8 | F3:8 A3:8 C4:8 F4:8 C4:8 A3:8 C4:8 A3:8 | G3:8 B3:8 D4:8 G4:8 D4:8 B3:8 D4:8 B3:8 | C4:8 E4:8 G4:8 C5:8 G4:8 E4:8 G4:8 E4:8 | A3:8 C4:8 E4:8 A4:8 E4:8 C4:8 E4:8 C4:8 | F3:8 A3:8 C4:8 F4:8 C4:8 A3:8 C4:8 A3:8 | G3:8 B3:8 D4:8 G4:8 D4:8 B3:8 D4:8 B3:8",
        "bars": 8,
        "bass": "C3:4 G3:4 C3:4 G3:4 | A2:4 E3:4 A2:4 E3:4 | F2:4 C3:4 F2:4 C3:4 | G2:4 D3:4 G2:4 D3:4 | C3:4 G3:4 C3:4 G3:4 | A2:4 E3:4 A2:4 E3:4 | F2:4 C3:4 F2:4 C3:4 | G2:4 D3:4 G2:4 D3:4",
        "drums": "kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:8 snare:8 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:8 snare:8 hihat:4",
        "harmony": "[C4,E4,G4]:1 | [A3,C4,E4]:1 | [F3,A3,C4]:1 | [G3,B3,D4]:1 | [C4,E4,G4]:1 | [A3,C4,E4]:1 | [F3,A3,C4]:1 | [G3,B3,D4]:1",
        "lead": "C6:4 G5:8 E5:8 G5:2 | A5:4 C6:4 B5:8 A5:8 G5:4 | A5:8 G5:8 F5:4 E5:8 F5:8 G5:4 | D5:4 G5:4 B5:4 G5:4 | E6:8 D6:8 C6:4 G5:4 E5:4 | A5:8 B5:8 C6:4 E6:4 C6:4 | F6:4 E6:8 D6:8 C6:4 A5:4 | G5:4 B5:4 C6:2"
    },
    "coda": {
        "arp": "C4:8 E4:8 G4:8 C5:8 G4:8 E4:8 G4:8 E4:8 | A3:8 C4:8 E4:8 A4:8 E4:8 C4:8 E4:8 C4:8 | F3:8 A3:8 C4:8 F4:8 C4:8 A3:8 C4:8 A3:8 | G3:8 B3:8 D4:8 G4:8 D4:8 B3:8 D4:8 B3:8",
        "bars": 4,
        "bass": "C3:4 G3:4 C3:4 G3:4 | A2:4 E3:4 A2:4 E3:4 | F2:4 C3:4 F2:4 C3:4 | G2:4 D3:4 G2:4 D3:4",
        "drums": "kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:8 snare:8 hihat:4",
        "harmony": "[C4,E4,G4]:1 | [A3,C4,E4]:1 | [F3,A3,C4]:1 | [G3,B3,D4]:1",
        "lead": "E5:8 D5:8 C5:4 G4:4 C5:4 | A5:4 G5:4 E5:2 | F5:4 E5:4 D5:4 B4:4 | C5:2 G4:4 C5:4"
    },
    "intro": {
        "arp": "C4:8 E4:8 G4:8 C5:8 G4:8 E4:8 G4:8 E4:8 | A3:8 C4:8 E4:8 A4:8 E4:8 C4:8 E4:8 C4:8 | F3:8 A3:8 C4:8 F4:8 C4:8 A3:8 C4:8 A3:8 | G3:8 B3:8 D4:8 G4:8 D4:8 B3:8 D4:8 B3:8",
        "bars": 4,
        "bass": "C3:2 G3:2 | A2:2 E3:2 | F2:2 C3:2 | G2:2 D3:2",
        "harmony": "[C4,E4,G4]:1 | [A3,C4,E4]:1 | [F3,A3,C4]:1 | [G3,B3,D4]:1",
        "lead": "C5:2 G4:4 E5:4 | A4:2 E5:2 | F5:4 E5:4 C5:2 | D5:4 G5:4 B5:2"
    },
    "pre_chorus": {
        "arp": "F3:8 A3:8 C4:8 F4:8 C4:8 A3:8 C4:8 A3:8 | G3:8 B3:8 D4:8 G4:8 D4:8 B3:8 D4:8 B3:8 | C4:8 E4:8 G4:8 C5:8 G4:8 E4:8 G4:8 E4:8 | A3:8 C4:8 E4:8 A4:8 E4:8 C4:8 E4:8 C4:8",
        "bars": 4,
        "bass": "F2:4 C3:4 F2:4 C3:4 | G2:4 D3:4 G2:4 D3:4 | C3:4 G3:4 C3:4 G3:4 | A2:4 E3:4 A2:4 E3:4",
        "drums": "kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:8 snare:8 hihat:4",
        "harmony": "[F3,A3,C4]:1 | [G3,B3,D4]:1 | [C4,E4,G4]:1 | [A3,C4,E4]:1",
        "lead": "F5:4 A5:4 C6:2 | E5:8 G5:8 A5:4 B5:2 | F5:4 A5:8 C6:8 D6:4 C6:4 | B5:4 G5:4 D5:4 G5:4"
    },
    "verse": {
        "arp": "C4:8 E4:8 G4:8 C5:8 G4:8 E4:8 G4:8 E4:8 | A3:8 C4:8 E4:8 A4:8 E4:8 C4:8 E4:8 C4:8 | F3:8 A3:8 C4:8 F4:8 C4:8 A3:8 C4:8 A3:8 | G3:8 B3:8 D4:8 G4:8 D4:8 B3:8 D4:8 B3:8 | C4:8 E4:8 G4:8 C5:8 G4:8 E4:8 G4:8 E4:8 | A3:8 C4:8 E4:8 A4:8 E4:8 C4:8 E4:8 C4:8 | F3:8 A3:8 C4:8 F4:8 C4:8 A3:8 C4:8 A3:8 | G3:8 B3:8 D4:8 G4:8 D4:8 B3:8 D4:8 B3:8",
        "bars": 8,
        "bass": "C3:4 G3:4 C3:4 G3:4 | A2:4 E3:4 A2:4 E3:4 | F2:4 C3:4 F2:4 C3:4 | G2:4 D3:4 G2:4 D3:4 | C3:4 G3:4 C3:4 G3:4 | A2:4 E3:4 A2:4 E3:4 | F2:4 C3:4 F2:4 C3:4 | G2:4 D3:4 G2:4 D3:4",
        "drums": "kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:8 snare:8 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:4 hihat:4 | kick:4 hihat:8 hihat:8 snare:8 snare:8 hihat:4",
        "harmony": "[C4,E4,G4]:1 | [A3,C4,E4]:1 | [F3,A3,C4]:1 | [G3,B3,D4]:1 | [C4,E4,G4]:1 | [A3,C4,E4]:1 | [F3,A3,C4]:1 | [G3,B3,D4]:1",
        "lead": "C5:8 E5:8 G5:4 E5:8 C5:8 D5:4 | E5:8 G5:8 A5:4 G5:4 E5:4 | F5:8 A5:8 G5:4 E5:8 D5:8 C5:4 | D5:8 E5:8 G5:4 D5:4 C5:4 | E5:8 D5:8 C5:4 G4:4 C5:4 | A5:8 G5:8 E5:4 C5:8 E5:8 G5:4 | F5:4 E5:8 D5:8 C5:4 A4:4 | B4:8 D5:8 G5:4 D5:4 G4:4"
    }
}
arrangement = ["intro","verse","pre_chorus","chorus","verse","bridge","breakdown","chorus","coda"]

@Music/marble_title
type = synth
tempo = 96
time_signature = 4/4
loop = true
volume = 0.045
instruments = {"lead":"bell","harmony":"strings","bass":"triangle"}
sections = {
    "welcome": {
        "bars": 4,
        "bass": "C3:1 | A2:1 | F2:1 | G2:1",
        "harmony": "[C4,E4,G4]:1 | [A3,C4,E4]:1 | [F3,A3,C4]:1 | [G3,B3,D4]:1",
        "lead": "C5:2 G5:4 E5:4 | A5:2 E5:2 | F5:4 E5:4 C5:2 | D5:4 G4:4 C5:2"
    }
}
arrangement = ["welcome"]

@Sound/marble_shatter
wave = noise
sequence = C5:40ms, G4:60ms, C3:120ms, C2:120ms
volume = 0.11

@Sound/marble_start
wave = sine
sequence = C4:60ms, E4:60ms, G4:100ms
volume = 0.1

@Sound/marble_menu
wave = sine
sequence = C5:30ms, E5:30ms
volume = 0.05
title.rune
@Perspective/marble_title_view
fov = 70

@Camera/marble_attract_camera
duration = 28
loop = true
points = [
    {"x":0,"y":2,"height":10,"angle":31,"pitch":-28},
    {"x":16,"y":-2,"height":9,"angle":121,"pitch":-27},
    {"x":20,"y":14,"height":10,"angle":211,"pitch":-28},
    {"x":4,"y":18,"height":9,"angle":301,"pitch":-27}
]

@Scene/marble_title_scene
map = valley
things = ["factory","title_props"]
camera = marble_attract_camera
perspective = marble_title_view
heading = MARBLE RUN
prompt = ENTER START / L LEVELS
Built entirely with Rune-Web