Vue du dessus
Simon
Charger un atlas images
Section intitulée « Charger un atlas images »load.js function loadAtlas() {loadSpriteAtlas("assets/sprites/clementine-atlas.png", {"clementine": {x: 0, y: 0,width: 244, height: 53,sliceX: 4,anims: {idle: { from: 0, to: 0 },run: { from: 0, to: 0 },sleep: { from: 1, to: 1 },jump: { from: 2, to: 2 },worry: { from: 3, to: 3 },},},})loadSpriteAtlas("assets/sprites/bean-atlas.png", {"bean": {x: 0, y: 0,width: 244, height: 53,sliceX: 4,anims: {idle: { from: 0, to: 0 },run: { from: 0, to: 0 },sleep: { from: 1, to: 1 },jump: { from: 2, to: 2 },worry: { from: 3, to: 3 },},},})loadSpriteAtlas("assets/sprites/splash.png", {"splash": {x: 0, y: 0,width: 384, height: 64,sliceX: 6,anims: { explode: { from: 0, to: 5, speed:30 } },},})}configurer les niveaux
Section intitulée « configurer les niveaux »config.js level not foundDéclarer un objet
Section intitulée « Déclarer un objet »config.js const TILE_CONFIG = {"@": () => [ // player 1sprite("clementine"),pos(0, -32),topdownController(),alive(),opacity(),scale(),health(1),area({shape: new Polygon([vec2(28, -12), vec2(28, 12), vec2(12, 24), vec2(-12, 24), vec2(-28, 12), vec2(-28, -12), vec2(-12, -24), vec2(12, -24),])}),anchor("center"),body(),respawn(),rotate(),"player",],"#": () => [ // player 1sprite("bean"),platformerController(),jumpController(),sleep(),alive(),opacity(),scale(),health(1, 4),area(),body(),respawn(),falling(),rotate(),pos(0, -20),anchor("center"),],"=": () => [ // blocksprite("grass"),area({ collisionIgnore: ["agent"] }),body({ isStatic: true }),anchor("bot"),offscreen({ hide: true }),tile({ isObstacle: true }),],}Placer les objets
Section intitulée « Placer les objets »level.js const LEVELS = [{map: `====================== = == = === = == @ = = = == === = == = = = == = = ======================`,},]
Paramètres
Section intitulée « Paramètres »topdownController()
exampleconfig.js
topdownController({ upKey: ["up", "z"], leftKey: ["left", "q"], rightKey: ["right", "d"], downKey: ["down", "s"], moveSpeed: 480, rotationDelay: 0.04, accelerationtionDelay: 0.04, rotation: -90, startRotation: 90, rotateSprite: true}),