Levels in Kaboom.js

Question:
Kaboom.js playground code is outdated, gives a bunch of errors like “grid width and height need to be defined” and stuff. I’ve got it to run without errors but the level isn’t showing up. I really don’t want to make my own level system, but I’ll have to if this just isn’t gonna work.

Repl link:
https://replit.com/@QwertyQwerty88/Mario#code/game.js

const LEVELS = [
    [
        "=====",
        "=====",
        "=====",
        "=====",
        "====="
    ]
]

const levelConfig = {
    width: 32,
    height: 32,
    tiles: {
        "=": () => [
            sprite("gold block"),
            area(),
            solid()
        ]
    }
}

scene("game", ({ levelId, coins } = { levelId: 0, coins: 0 }) => {
    const level = addLevel(LEVELS[levelId ?? 0], levelConfig)
    
    onKeyPress("f", () => fullscreen(!isFullscreen()))
})

go("game")

MB, it’s not outdated, I’m using 2000 instead of 3000, so

should just be

"=": () => [
    sprite("gold block"),
    area(),
    solid()
]

what a silly mistake lol

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.