Blocs traversables

Les blocs traversables permettent de faciliter la circulation du joueur.

Charger une image

load.js
const PNG = [ "small-grass", "grass", ]

Déclarer un symbole

levelConf.js
const LEVEL_CONFIG = { // paramètres du niveau tileWidth: 64, tileHeight: 64, backgroundColor: "afe1ff", gravity: 3200, tiles: { // listes des objets à placer dans les niveaux
"-": () => [ // block sprite("small-grass"), area(), body({ isStatic: true }), anchor("bot"), offscreen({ hide: true }), pos(0,-32), "pass through", ],
"#": () => [ // player sprite("bean"), platformerController(), alive(), opacity(), scale(), health(1, 4), area(), anchor("bot"), body(), respawn(), falling(), coloring(), animator(), ], "=": () => [ // block sprite("grass"), area(), body({ isStatic: true }), anchor("bot"), offscreen({ hide: true }), ], }, }

Placer les objets

level.js
const LEVELS = [ // liste des niveaux du jeu { map: ` ----- # ===== `, }, ];