silphius/app/create-homestead.js

66 lines
1.5 KiB
JavaScript
Raw Normal View History

2024-07-02 20:43:55 -05:00
import createEcs from './create-ecs.js';
2024-07-09 15:05:23 -05:00
export default async function createHomestead(Ecs, id) {
2024-07-02 20:43:55 -05:00
const ecs = createEcs(Ecs);
const area = {x: 100, y: 60};
await ecs.create({
AreaSize: {x: area.x * 16, y: area.y * 16},
2024-07-02 22:42:56 -05:00
Ticking: {},
2024-07-02 20:43:55 -05:00
TileLayers: {
layers: [
{
area,
data: Array(area.x * area.y).fill(0).map(() => 1 + Math.floor(Math.random() * 4)),
source: '/assets/tileset.json',
tileSize: {x: 16, y: 16},
2024-07-07 17:32:54 -05:00
},
{
area,
data: Array(area.x * area.y).fill(0),
source: '/assets/tileset.json',
tileSize: {x: 16, y: 16},
},
2024-07-02 20:43:55 -05:00
],
},
2024-07-04 15:17:33 -05:00
Time: {},
2024-07-02 20:43:55 -05:00
Water: {water: {}},
});
await ecs.create({
2024-07-02 22:42:56 -05:00
Collider: {
bodies: [
2024-07-03 16:13:14 -05:00
{
points: [
{x: -36, y: 8},
{x: -21, y: 8},
{x: -36, y: 17},
{x: -21, y: 17},
],
tags: ['door'],
},
{
impassable: 1,
points: [
{x: -52, y: -16},
2024-07-04 21:47:14 -05:00
{x: 44, y: -16},
2024-07-03 16:13:14 -05:00
{x: -52, y: 15},
2024-07-04 21:47:14 -05:00
{x: 44, y: 15},
2024-07-03 16:13:14 -05:00
],
},
2024-07-02 22:42:56 -05:00
],
collisionStartScript: '/assets/shit-shack/collision-start.js',
},
2024-07-09 15:05:23 -05:00
Ecs: {
path: ['houses', `${id}`].join('/'),
},
2024-07-02 20:43:55 -05:00
Position: {x: 100, y: 100},
Sprite: {
2024-07-03 21:56:55 -05:00
anchorX: 0.5,
anchorY: 0.8,
2024-07-02 20:43:55 -05:00
source: '/assets/shit-shack/shit-shack.json',
},
2024-07-04 15:17:33 -05:00
Ticking: {},
2024-07-02 20:43:55 -05:00
VisibleAabb: {},
});
return ecs;
}