Aller au contenu

Épée

Anton & Paul
  1. load.js
    const PNG = [
    'sword',
    'turnip',
    'grass',
    ];
  2. load.js
    const MP3 = [
    'sword',
    'wooosh',
    'off',
    ];
  3. 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',
    ],
  4. config.js
    const TILE_CONFIG = {
    // navet
    t: () => [
    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 }),
    ],
    };
  5. events.js
    function events() {
    return {
    add() {
    // épée
    on('sword impact', 'blade', () => play('sword'));
    // personnages
    on('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;
    }
    });
    });
    // joueur
    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) => {
    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'),
    });
    });
    },
    };
    }
  6. level.js
    const LEVELS = [
    {
    map: `
    t # t
    ===========
    `,
    },
    ]
sword()
example
config.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()
example
config.js
swordController({
shootKey: 'space',
keyPressToShoot: true,
mousePressToShoot: true,
sequenceBreakDelay: 0.2,
delay: 0.1,
postureBreak: true,
postureBreakDelay: 0.2,
moveSequence: [],
onJumpMoveSequence: []
}),
handSprite()
example
config.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()
example
config.js
facingAimController({
aimAngleMargin: 0
}),
sight()
example
config.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()
example
config.js
danger({
damage: 1,
collisions: ['top', 'left', 'bot', 'right'],
ongoing: false,
tag: '*',
on: true
}),
swordAi()
example
config.js
swordAi({
delay: 1,
tag: 'player',
autoAim: true,
horizontalAim: false,
aimMargin: vec2(0, 0),
postureBreak: true,
postureBreakDelay: 1,
firstSlayDelay: 0,
moveSequence: [],
sight: 180
}),