43 lines
898 B
JavaScript
43 lines
898 B
JavaScript
import createEcs from './create-ecs.js';
|
|
|
|
export default async function createHouse(Ecs) {
|
|
const ecs = createEcs(Ecs);
|
|
const area = {x: 20, y: 20};
|
|
await ecs.create({
|
|
AreaSize: {x: area.x * 16, y: area.y * 16},
|
|
Ticking: {},
|
|
TileLayers: {
|
|
layers: [
|
|
{
|
|
area,
|
|
data: Array(area.x * area.y).fill(0).map(() => 5 + Math.floor(Math.random() * 2)),
|
|
source: '/assets/tileset.json',
|
|
tileSize: {x: 16, y: 16},
|
|
}
|
|
],
|
|
},
|
|
});
|
|
await ecs.create({
|
|
Collider: {
|
|
bodies: [
|
|
{
|
|
points: [
|
|
{x: -8, y: -8},
|
|
{x: 7, y: -8},
|
|
{x: 7, y: 7},
|
|
{x: -8, y: 7},
|
|
],
|
|
},
|
|
],
|
|
collisionStartScript: '/assets/house/collision-start.js',
|
|
},
|
|
Ecs: {},
|
|
Position: {
|
|
x: 72,
|
|
y: 320,
|
|
},
|
|
Ticking: {},
|
|
});
|
|
return ecs;
|
|
}
|