Tirer
Enam
Charger des images
Section intitulée « Charger des images »load.js const PNG = ['bullet','gun','radish','cross-cursor','grass',];Charger un son
Section intitulée « Charger un son »load.js const MP3 = ['shoot','bim','wooosh','off',];Déclarer un objet
Section intitulée « Déclarer un objet »config.js const TILE_CONFIG = {// radisR: () => [sprite('radish'),alive(),opacity(),scale(),health(3),respawn(),body(),area({ scale: vec2(1, 0.8) }),handSprite(),sight({ sight: 560, loosingSight: 800 }),shoot(),shootAi(),pos(32, 32),anchor('center'),],// 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 }),],};modifier le joueur
Section intitulée « modifier le joueur »config.js // player'#': () => [shoot(),handSprite(),shootController(),mouseAimController(),sprite('bean'),platformerController(),jumpController(),sleep(),alive(),opacity(),scale(),health(1, 4),area(),body(),respawn(),falling(),rotate(),pos(0, -20),anchor('center'),'player',],Lancer une animation
Section intitulée « Lancer une animation »events.js function events() {return {add() {// tireron('shoot', 'shoot', () => play('shoot'));on('impact', 'projectile', (obj) => {splashFX(obj.worldPos);play('bim');destroy(obj);});// 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: `R=R=R= =#===========`,},]
Paramètres
Section intitulée « Paramètres »shoot()
exampleconfig.js
shoot({ speed: 1200, pos: vec2(0, 0), lifespan: 0.01, fadeOut: 0.4, sprite: 'bullet', width: "null", bulletTag: "null", impactTag: '*', dangerParam: {}, bounceParam: {}, startDistance: 64, gravityScale: 0, destroyOnImpact: true, bounciness: 0, friction: 0, aimAngle: 0}),shootController()
exampleconfig.js
shootController({ shootKey: 'space', keyPressToShoot: true, mousePressToShoot: true, delay: 0.2}),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}),mouseAimController()
exampleconfig.js
mouseAimController({ sprite: 'cross-cursor', width: 26, margin: vec2(0, 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}),destroyOnEvent()
exampleconfig.js
destroyOnEvent({ delay: 0.4, event: 'death', on: true}),bounce()
exampleconfig.js
bounce({ direction: vec2(0, 0), speed: 0, bounciness: 0.8, friction: 0.5, detuneAmp: 400, tag: '*'}),shootAi()
exampleconfig.js
shootAi({ delay: 2, tag: 'player', autoAim: true, aimMargin: vec2(0, 0), postureBreak: false, postureBreakDelay: 1}),