humus-old/server/create-server-room.js

77 lines
2.3 KiB
JavaScript
Raw Normal View History

2019-03-27 15:51:58 -05:00
import {World} from '@avocado/physics/matter/world';
import {Room} from '@avocado/topdown';
// A flower barrel.
function flowerBarrelJSON(position) {
return {
traits: {
2019-04-08 15:20:43 -05:00
collider: {},
existent: {},
graphical: {},
physical: {},
2019-03-27 15:51:58 -05:00
pictured: {
params: {
images: {
initial: {
offset: [0, -8],
size: [32, 32], // Derive?
uri: '/flower-barrel.png',
},
}
},
},
2019-04-08 13:32:52 -05:00
positioned: {
state: {
x: position[0],
y: position[1],
},
},
shaped: {
2019-03-27 15:51:58 -05:00
params: {
shape: {
type: 'rectangle',
position: [0, 0],
size: [20, 10],
2019-04-08 13:32:52 -05:00
},
2019-03-27 15:51:58 -05:00
},
},
},
};
}
// Room.
const roomJSON = {
2019-03-28 02:14:57 -05:00
size: [384, 192],
2019-03-27 17:16:09 -05:00
layers: {
everything: {
2019-03-27 15:51:58 -05:00
entities: [],
tiles: {
2019-03-28 02:14:57 -05:00
size: [24, 12],
2019-03-27 15:51:58 -05:00
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,
2019-03-28 03:12:03 -05:00
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,
2019-03-27 15:51:58 -05:00
],
},
tilesetUri: '/tileset.json',
2019-03-27 15:51:58 -05:00
},
2019-03-27 17:16:09 -05:00
},
2019-03-27 15:51:58 -05:00
};
for (let i = 0; i < 10; ++i) {
const x = Math.floor(Math.random() * 200) + 50;
const y = Math.floor(Math.random() * 75) + 50;
2019-03-27 17:16:09 -05:00
roomJSON.layers.everything.entities.push(flowerBarrelJSON([x, y]));
2019-03-27 15:51:58 -05:00
}
export function createRoom() {
2019-03-27 16:11:49 -05:00
const room = (new Room()).fromJSON(roomJSON);
2019-03-27 15:51:58 -05:00
room.world = new World();
2019-03-27 16:11:49 -05:00
return room;
2019-03-27 15:51:58 -05:00
}