75 lines
2.3 KiB
JavaScript
75 lines
2.3 KiB
JavaScript
import {World} from '@avocado/physics/matter/world';
|
|
import {Room} from '@avocado/topdown';
|
|
// A flower barrel.
|
|
function flowerBarrelJSON(position) {
|
|
return {
|
|
traits: {
|
|
pictured: {
|
|
params: {
|
|
images: {
|
|
initial: {
|
|
offset: [0, -8],
|
|
size: [32, 32], // Derive?
|
|
uri: '/flower-barrel.png',
|
|
},
|
|
}
|
|
},
|
|
},
|
|
existent: {},
|
|
graphical: {},
|
|
physical: {
|
|
params: {
|
|
shape: {
|
|
type: 'rectangle',
|
|
position: [0, 0],
|
|
size: [20, 10],
|
|
}
|
|
}
|
|
},
|
|
positioned: {
|
|
state: {
|
|
x: position[0],
|
|
y: position[1],
|
|
},
|
|
},
|
|
},
|
|
};
|
|
}
|
|
// Room.
|
|
const roomJSON = {
|
|
size: [384, 192],
|
|
layers: {
|
|
everything: {
|
|
entities: [],
|
|
tiles: {
|
|
size: [24, 12],
|
|
data: [
|
|
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
|
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
|
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
|
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
|
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
|
1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
|
1, 2, 3, 4, 1, 2, 3, 4, 21, 22, 23, 24, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
|
1, 2, 3, 4, 1, 2, 3, 4, 261, 262, 263, 264, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
|
1, 2, 3, 4, 1, 2, 3, 4, 277, 278, 279, 280, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
|
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
|
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
|
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
|
],
|
|
},
|
|
tilesetUri: '/tileset.json',
|
|
},
|
|
},
|
|
};
|
|
for (let i = 0; i < 10; ++i) {
|
|
const x = Math.floor(Math.random() * 200) + 50;
|
|
const y = Math.floor(Math.random() * 75) + 50;
|
|
roomJSON.layers.everything.entities.push(flowerBarrelJSON([x, y]));
|
|
}
|
|
export function createRoom() {
|
|
const room = (new Room()).fromJSON(roomJSON);
|
|
room.world = new World();
|
|
return room;
|
|
}
|