Updated sprites and pet logic
This commit is contained in:
135
assets/pets/maple.js
Normal file
135
assets/pets/maple.js
Normal file
@@ -0,0 +1,135 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const { pathToFileURL } = require('url');
|
||||
|
||||
const SHEET_WIDTH = 1536;
|
||||
const SHEET_HEIGHT = 1872;
|
||||
const CELL_WIDTH = 192;
|
||||
const CELL_HEIGHT = 208;
|
||||
const SHEET_URL = pathToFileURL(path.join(__dirname, 'maple', 'spritesheet.webp')).href;
|
||||
|
||||
function cell(row, col, facingBasis) {
|
||||
return {
|
||||
sheetUrl: SHEET_URL,
|
||||
sheetWidth: SHEET_WIDTH,
|
||||
sheetHeight: SHEET_HEIGHT,
|
||||
frameX: col * CELL_WIDTH,
|
||||
frameY: row * CELL_HEIGHT,
|
||||
frameWidth: CELL_WIDTH,
|
||||
frameHeight: CELL_HEIGHT,
|
||||
facingBasis: facingBasis || 'left'
|
||||
};
|
||||
}
|
||||
|
||||
function rowFrames(row, startCol, count, facingBasis) {
|
||||
const frames = [];
|
||||
for (let index = 0; index < count; index += 1) {
|
||||
frames.push(cell(row, startCol + index, facingBasis));
|
||||
}
|
||||
return frames;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
width: 48,
|
||||
height: 52,
|
||||
clips: {
|
||||
idle0: {
|
||||
fps: 1.4,
|
||||
frames: rowFrames(0, 0, 6, 'left')
|
||||
},
|
||||
idle1: {
|
||||
fps: 1.4,
|
||||
frames: rowFrames(6, 0, 6, 'left')
|
||||
},
|
||||
idle2: {
|
||||
fps: 1.4,
|
||||
frames: rowFrames(7, 0, 6, 'left')
|
||||
},
|
||||
idle3: {
|
||||
fps: 1.4,
|
||||
frames: rowFrames(8, 0, 6, 'left')
|
||||
},
|
||||
walkRight: {
|
||||
fps: 4.4,
|
||||
frames: rowFrames(1, 0, 8, 'right')
|
||||
},
|
||||
walkLeft: {
|
||||
fps: 4.4,
|
||||
frames: rowFrames(2, 0, 8, 'left')
|
||||
},
|
||||
inspectLeft: {
|
||||
fps: 2.2,
|
||||
frames: rowFrames(3, 0, 4, 'left')
|
||||
},
|
||||
inspectRight: {
|
||||
fps: 2.2,
|
||||
frames: rowFrames(3, 0, 4, 'left')
|
||||
},
|
||||
pounceLeft: {
|
||||
fps: 4,
|
||||
frames: rowFrames(4, 0, 5, 'left')
|
||||
},
|
||||
pounceRight: {
|
||||
fps: 4,
|
||||
frames: rowFrames(4, 0, 5, 'left')
|
||||
},
|
||||
sleep: {
|
||||
fps: 1,
|
||||
frames: [
|
||||
cell(5, 3, 'left')
|
||||
]
|
||||
},
|
||||
sleepWakeLeft: {
|
||||
fps: 2.6,
|
||||
frames: rowFrames(5, 4, 3, 'left'),
|
||||
nextClip: 'idle0'
|
||||
},
|
||||
sleepWakeRight: {
|
||||
fps: 2.6,
|
||||
frames: rowFrames(5, 4, 3, 'left'),
|
||||
nextClip: 'idle0'
|
||||
},
|
||||
transitionIdleWalkLeft: {
|
||||
fps: 3,
|
||||
frames: rowFrames(2, 0, 3, 'left'),
|
||||
nextClip: 'walkLeft'
|
||||
},
|
||||
transitionIdleWalkRight: {
|
||||
fps: 3,
|
||||
frames: rowFrames(1, 0, 3, 'right'),
|
||||
nextClip: 'walkRight'
|
||||
},
|
||||
transitionIdleSleep: {
|
||||
fps: 2.8,
|
||||
frames: rowFrames(5, 0, 4, 'left'),
|
||||
nextClip: 'sleep'
|
||||
}
|
||||
},
|
||||
transitions: {
|
||||
'idle0->walkLeft': 'transitionIdleWalkLeft',
|
||||
'idle1->walkLeft': 'transitionIdleWalkLeft',
|
||||
'idle2->walkLeft': 'transitionIdleWalkLeft',
|
||||
'idle3->walkLeft': 'transitionIdleWalkLeft',
|
||||
'idle0->walkRight': 'transitionIdleWalkRight',
|
||||
'idle1->walkRight': 'transitionIdleWalkRight',
|
||||
'idle2->walkRight': 'transitionIdleWalkRight',
|
||||
'idle3->walkRight': 'transitionIdleWalkRight',
|
||||
'idle0->sleep': 'transitionIdleSleep',
|
||||
'idle1->sleep': 'transitionIdleSleep',
|
||||
'idle2->sleep': 'transitionIdleSleep',
|
||||
'idle3->sleep': 'transitionIdleSleep',
|
||||
'inspectLeft->walkLeft': 'transitionIdleWalkLeft',
|
||||
'inspectRight->walkRight': 'transitionIdleWalkRight',
|
||||
'sleep->idle0': 'sleepWakeLeft',
|
||||
'sleep->idle1': 'sleepWakeLeft',
|
||||
'sleep->idle2': 'sleepWakeLeft',
|
||||
'sleep->idle3': 'sleepWakeLeft',
|
||||
'sleep->walkLeft': 'sleepWakeLeft',
|
||||
'sleep->walkRight': 'sleepWakeRight',
|
||||
'sleep->inspectLeft': 'sleepWakeLeft',
|
||||
'sleep->inspectRight': 'sleepWakeRight',
|
||||
'sleep->pounceLeft': 'sleepWakeLeft',
|
||||
'sleep->pounceRight': 'sleepWakeRight'
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user