Aller au contenu

Bloc traversable

Sullivan
  1. load.js
    const PNG = [
    "small-grass",
    "grass",
    ]
  2. config.js
    const TILE_CONFIG = {
    "-": () => [ // block
    sprite("small-grass"),
    area(),
    body({ isStatic: true }),
    anchor("bot"),
    offscreen({ hide: true }),
    pos(0, -32),
    "pass through",
    ],
    "#": () => [ // player 1
    sprite("bean"),
    platformerController(),
    jumpController(),
    sleep(),
    alive(),
    opacity(),
    scale(),
    health(1, 4),
    area(),
    body(),
    respawn(),
    falling(),
    rotate(),
    pos(0, -20),
    anchor("center"),
    ],
    "=": () => [ // block
    sprite("grass"),
    area({ collisionIgnore: ["agent"] }),
    body({ isStatic: true }),
    anchor("bot"),
    offscreen({ hide: true }),
    tile({ isObstacle: true }),
    ],
    }
  3. config.js
    "#": () => [ // player 1
    passThroughController(),
    sprite("bean"),
    platformerController(),
    jumpController(),
    sleep(),
    alive(),
    opacity(),
    scale(),
    health(1, 4),
    area(),
    body(),
    respawn(),
    falling(),
    rotate(),
    pos(0, -20),
    anchor("center"),
    ],
  4. level.js
    const LEVELS = [
    {
    map: `
    -----
    #
    =====
    `,
    },
    ]
passThroughController()
example
config.js
passThroughController({
downKey: "down"
}),