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('top'),
    offscreen({ hide: true }),
    pos(32, 0),
    'pass through',
    ],
    // player
    '#': () => [
    sprite('bean'),
    platformerController(),
    jumpController(),
    sleep(),
    alive(),
    opacity(),
    scale(),
    health(1, 4),
    area(),
    body(),
    respawn(),
    falling(),
    rotate(),
    pos(0, -20),
    anchor('center'),
    'player',
    ],
    // block
    '=': () => [
    sprite('grass-tileset'),
    offscreen({ hide: true }),
    tile({ isObstacle: true }),
    autoTiling(),
    area(),
    body({ isStatic: true }),
    ],
    };
  3. config.js
    // player
    '#': () => [
    passThroughController(),
    sprite('bean'),
    platformerController(),
    jumpController(),
    sleep(),
    alive(),
    opacity(),
    scale(),
    health(1, 4),
    area(),
    body(),
    respawn(),
    falling(),
    rotate(),
    pos(0, -20),
    anchor('center'),
    'player',
    ],
  4. level.js
    const LEVELS = [
    {
    map: `
    -----
    #
    =====
    `,
    },
    ]
passThroughController()
example
config.js
passThroughController({
downKey: 'down'
}),