silphius/app/create-player.js

66 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-07-02 20:43:55 -05:00
export default async function createPlayer(id) {
const player = {
Camera: {},
2024-07-02 22:42:56 -05:00
Collider: {
bodies: [
2024-07-03 16:13:14 -05:00
{
points: [
{x: -8, y: -8},
{x: 7, y: -8},
{x: 7, y: 7},
{x: -8, y: 7},
],
},
2024-07-02 22:42:56 -05:00
],
},
2024-07-02 20:43:55 -05:00
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},
2024-07-03 19:05:40 -05:00
Magnet: {strength: 24},
2024-07-03 21:57:07 -05:00
Player: {},
2024-07-02 22:42:56 -05:00
Position: {x: 128, y: 128},
2024-07-02 20:43:55 -05:00
Speed: {speed: 100},
Sound: {},
Sprite: {
2024-07-03 21:56:55 -05:00
anchorX: 0.5,
anchorY: 0.8,
2024-07-02 20:43:55 -05:00
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));
}