Attraper et lancer
Arthur
Charger des images
Section intitulée « Charger des images »load.js const PNG = ["ball","grass",]Charger un son
Section intitulée « Charger un son »load.js const MP3 = ["shoot","bim","score","bloup","wooosh","off",]Déclarer un objet
Section intitulée « Déclarer un objet »config.js const TILE_CONFIG = {"°": () => [ // ballesprite("ball"),area(),anchor("bot"),respawn(),body(),catchable({ type: "ball" }),falling(),],"#": () => [ // 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 1holdItem(),handSprite({ hiddenOnStart: true }),facingAimController({aimAngleMargin: -20,}),throwItem({dangerParam:{on:false},}),throwItemController(),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('bounce', 'catchable', (obj, p) => play('bloup', p))on('picked', 'hold', () => play("score"))on('grab catch', 'hand', (obj, p) => { tween(p.dist, obj.hand.pos, 0.2, (v) => obj.hand.pos = v, easings.easeOutSine); obj.hand.pos = p.dist })on('dropped', 'catchable', (obj, p) => tween(p.parentPos, p.pos, 0.2, (v) => obj.pos = v, easings.easeOutSine))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: `============ == == == == ° # ============`,},]
Paramètres
Section intitulée « Paramètres »holdItem()
exampleconfig.js
holdItem({ pos: vec2(0, -30), item: "{", sprite: "key", holdItemType: "key"}),facingAimController()
exampleconfig.js
facingAimController({ aimAngleMargin: 0}),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}),throwItem()
exampleconfig.js
throwItem({ speed: 800, pos: vec2(0, 0), sprite: "bullet", width: "null", bulletTag: "null", impactTag: "body", dangerParam: {}, bounceParam: {}, startDistance: 80, gravityScale: 1, destroyOnImpact: false, bounciness: 1, friction: 0, aimAngle: 40, type: "item"}),throwItemController()
exampleconfig.js
throwItemController({ shootKey: "space", keyPressToShoot: true, mousePressToShoot: true}),