Aller au contenu

Bloc glissant

Les blocs qui glissent créent une inertie dans les déplacements du joueur et ajoutent un délai aux changements de directions qu’il opère. Ces blocs peuvent être utilisés pour bousculer les habitudes du joueur en rendant son personnage plus difficile à contrôler.

  1. load.js
    const PNG = [
    "icy",
    "grass",
    ]
  2. config.js
    const LEVEL_CONFIG = {
    // paramètres du niveau
    tileWidth: 64,
    tileHeight: 64,
    backgroundColor: "afe1ff",
    gravity: 3200,
    tiles: {
    "%": () => [ // bloc qui glisse
    sprite("icy"),
    area(),
    body({ isStatic: true }),
    anchor("bot"),
    offscreen({ hide: true }),
    { glide: 2 },
    ],
    "#": () => [ // player 1
    sprite("bean"),
    platformerController(),
    alive(),
    opacity(),
    scale(),
    health(1, 4),
    area(),
    anchor("bot"),
    body(),
    respawn(),
    falling(),
    ],
    "=": () => [ // block
    sprite("grass"),
    area(),
    body({ isStatic: true }),
    anchor("bot"),
    offscreen({ hide: true }),
    ],
    },
    }
  3. level.js
    const LEVELS = [
    {
    map: `
    ===
    %%
    %%%%%%
    %%%%%
    #
    ===== %%%
    `,
    },
    ]
example
config.js
{ glide : 2 },