Épée
Anton & Paul
Charger des images
Section intitulée « Charger des images »load.js const PNG = ['sword','turnip','grass',];Charger un son
Section intitulée « Charger un son »load.js const MP3 = ['sword','wooosh','off',];modifier le joueur
Section intitulée « modifier le joueur »config.js // player'#': () => [swordController({moveSequence: [{bladeSwingAmp: 90,bladeSwingDuration: 0.15,wristSwingAmp: 90,wristSwingDuration: 0.15,},{bladeSwingAmp: -90,bladeSwingDuration: 0.15,wristSwingAmp: -90,wristSwingDuration: 0.15,},{stabDistance: 20,stabDuration: 0.1,},],onJumpMoveSequence: [{wristSwingAmp: 360,wristSwingAngle: 45,wristSwingDuration: 0.3,duration: 0.3,delay: 0.3,},],}),sword(),facingAimController(),sprite('bean'),platformerController(),jumpController(),sleep(),alive(),opacity(),scale(),health(1, 4),area(),body(),respawn(),falling(),rotate(),pos(0, -20),anchor('center'),'player',],Déclarer un objet
Section intitulée « Déclarer un objet »config.js const TILE_CONFIG = {// navett: () => [sprite('turnip'),swordAi(),sword({stabDistance: 20,stabDuration: 0.1,}),sight(),alive(),opacity(),scale(),health(3),anchor('bot'),respawn(),body(),area(),pos(32, 32),anchor('center'),rotate(),],// 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 }),],};Lancer une animation
Section intitulée « Lancer une animation »events.js function events() {return {add() {// épéeon('sword impact', 'blade', () => play('sword'));// personnageson('respawn', 'alive', (obj) => (obj.flipY = false));on('hurt', 'alive', (obj) => {play('hit');colorShiftFx(obj, { color: 'ff9b9b' });});on('death', 'alive', (obj) => {obj.flipY = true;wait(0.2, () => {if (!obj.isAlive) {obj.hidden = true;obj.collisionIgnore = ['*'];obj.isStatic = true;}});});// joueuron('respawn', 'player', (obj) => obj.play('idle'));on('sleep', 'player', (obj) => obj.play('sleep'));on('awake', 'player', (obj) => obj.play('idle'));on('jump', 'player', (obj) => {play('wooosh');obj.play('jump', {speed: 4,onEnd: () => obj.play('idle'),});});on('drop', 'player', (obj) => {play('off');obj.play('worry');});on('hurt', 'player', (obj) => {obj.play('worry', {speed: 2,onEnd: () => obj.play('idle'),});});},};}Placer les objets
Section intitulée « Placer les objets »level.js const LEVELS = [{map: `t # t===========`,},]
Paramètres
Section intitulée « Paramètres »sword()
exampleconfig.js
sword({ bladePos: vec2(38, 0), jointPos: vec2(0, 0), onGuardRotation: 20, onGuardPos: vec2(28, 10), onGuardSpeed: 0.4, rotation: 90, coolDownDelay: 0.4, sprite: 'sword', tag: '*', width: 29, danger: true, flipX: true, danger: {}, duration: 0.2, anchor: vec2(0, 0.8), areaScale: vec2(0.8, 0.6), areaOffset: vec2(0, -20), bladeSwingAngle: 0, bladeSwingAmp: 0, bladeSwingDuration: 0, wristSwingAngle: 0, wristSwingAmp: 0, wristSwingDuration: 0, stabDistance: 0, stabDuration: 0, impactPower: 6, impactDuration: 0.15, aimAngle: 0}),swordController()
exampleconfig.js
swordController({ shootKey: 'space', keyPressToShoot: true, mousePressToShoot: true, sequenceBreakDelay: 0.2, delay: 0.1, postureBreak: true, postureBreakDelay: 0.2, moveSequence: [], onJumpMoveSequence: []}),handSprite()
exampleconfig.js
handSprite({ sprite: 'gun', spriteParam: {}, handDistance: 40, jointPos: vec2(0, 0), anchor: vec2(0, 0), flipY: true, rotation: 0, rotate: true, aim: true, hiddenOnStart: false}),facingAimController()
exampleconfig.js
facingAimController({ aimAngleMargin: 0}),sight()
exampleconfig.js
sight({ sight: 180, looseSight: 340, raycast: false, tag: 'player', rayCastExclude: ['pass through'], offset: vec2(0, 0), on: true, offScreenPaused: false, liveUpdate: false, onAddOnly: false}),danger()
exampleconfig.js
danger({ damage: 1, collisions: ['top', 'left', 'bot', 'right'], ongoing: false, tag: '*', on: true}),swordAi()
exampleconfig.js
swordAi({ delay: 1, tag: 'player', autoAim: true, horizontalAim: false, aimMargin: vec2(0, 0), postureBreak: true, postureBreakDelay: 1, firstSlayDelay: 0, moveSequence: [], sight: 180}),