66 lines
1.3 KiB
JavaScript
66 lines
1.3 KiB
JavaScript
export default async function createPlayer(id) {
|
|
const player = {
|
|
Camera: {},
|
|
Collider: {
|
|
bodies: [
|
|
{
|
|
points: [
|
|
{x: -8, y: -8},
|
|
{x: 7, y: -8},
|
|
{x: 7, y: 7},
|
|
{x: -8, y: 7},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
Controlled: {},
|
|
Direction: {direction: 2},
|
|
Ecs: {path: ['forests', `${id}`].join('/')},
|
|
Emitter: {},
|
|
Forces: {},
|
|
Interacts: {},
|
|
Inventory: {
|
|
slots: {
|
|
1: {
|
|
qty: 100,
|
|
source: '/assets/potion/potion.json',
|
|
},
|
|
2: {
|
|
qty: 1,
|
|
source: '/assets/watering-can/watering-can.json',
|
|
},
|
|
3: {
|
|
qty: 1,
|
|
source: '/assets/tomato-seeds/tomato-seeds.json',
|
|
},
|
|
4: {
|
|
qty: 1,
|
|
source: '/assets/hoe/hoe.json',
|
|
},
|
|
},
|
|
},
|
|
Health: {health: 100},
|
|
Magnet: {strength: 24},
|
|
Player: {},
|
|
Position: {x: 128, y: 128},
|
|
Speed: {speed: 100},
|
|
Sound: {},
|
|
Sprite: {
|
|
anchorX: 0.5,
|
|
anchorY: 0.8,
|
|
animation: 'moving:down',
|
|
frame: 0,
|
|
frames: 8,
|
|
source: '/assets/dude/dude.json',
|
|
speed: 0.115,
|
|
},
|
|
Ticking: {},
|
|
VisibleAabb: {},
|
|
Wielder: {
|
|
activeSlot: 0,
|
|
},
|
|
};
|
|
return (new TextEncoder()).encode(JSON.stringify(player));
|
|
}
|
|
|