silphius/app/create-player.js
2024-07-02 20:43:55 -05:00

51 lines
1.1 KiB
JavaScript

export default async function createPlayer(id) {
const player = {
Camera: {},
Controlled: {},
Direction: {direction: 2},
Ecs: {path: ['homesteads', `${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},
Position: {x: 368, y: 368},
Speed: {speed: 100},
Sound: {},
Sprite: {
anchor: {x: 0.5, y: 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));
}