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 = {"R": () => [ // radissprite("radish"),alive(),opacity(),scale(),health(3),respawn(),body(),area({ scale: vec2(1, 0.8) }),handSprite(),sight(),shoot(),shootAi(),pos(0, -20),anchor("center"),],"#": () => [ // 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 }),],}modifier le joueur
Section intitulée « modifier le joueur »config.js "#": () => [ // player 1shoot(),handSprite(),shootController(),mouseAimController(),sprite("bean"),platformerController(),jumpController(),sleep(),alive(),opacity(),scale(),health(1, 4),area(),body(),respawn(),falling(),rotate(),pos(0, -20),anchor("center"),],Lancer une animation
Section intitulée « Lancer une animation »game.js scene("game", () => {const tiles = { ...TILE_CONFIG, ...LEVELS[CURRENT_LEVEL].tiles }const config = { ...LEVEL_CONFIG, ...LEVELS[CURRENT_LEVEL].config, ...{tiles:tiles}}const map = LEVELS[CURRENT_LEVEL].map.split('\n')const level = addLevel(map, config)const utility = add([multiplayerCamera(),])setGravity(config.gravity)setBackground(config.backgroundColor)on('shoot', 'shoot', () => play('shoot'))on('impact', 'projectile', (obj) => splashFX(obj.pos))on('impact', 'projectile', () => play('bim'))on('impact', 'projectile', (obj) => destroy(obj))on('jump', 'player', () => play('wooosh'))on('drop', 'player', () => play('off'))on('respawn', 'player', (obj) => obj.play('idle'))on('sleep', 'player', (obj) => obj.play('sleep'))on('awake', 'player', (obj) => obj.play('idle'))on('jump', 'player', (obj) => obj.play('jump', { speed: 4, onEnd: () => obj.play('idle') }))on('drop', 'player', (obj) => obj.play('worry'))}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: "body", 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", 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: 600, raycast: true, tag: "collectible", pos: vec2(0, 0)}),danger()
exampleconfig.js
danger({ damage: 1, collisions: ["top", "left", "bot", "right"], ongoing: false, tag: "alive", 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: "body"}),shootAi()
exampleconfig.js
shootAi({ delay: 2, tag: "player", autoAim: true, aimMargin: vec2(0, 0), postureBreak: false, postureBreakDelay: 1}),