chore: some flower barrels :3

This commit is contained in:
cha0s 2019-03-20 20:15:14 -05:00
parent acdc3f1924
commit d959dcdacf
2 changed files with 34 additions and 0 deletions

BIN
resource/flower-barrel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -24,6 +24,14 @@ const entityList = new EntityList();
const stateSynchronizer = new StateSynchronizer({
entityList,
});
setImmediate(() => {
for (let i = 0; i < 20; ++i) {
const x = Math.floor(Math.random() * 1000) + 100;
const y = Math.floor(Math.random() * 500) + 100;
const flowerBarrel = createFlowerBarrelEntity([x, y]);
entityList.addEntity(flowerBarrel);
}
});
// Connection listener.
function createConnectionListener(avocadoServer) {
return (socket) => {
@ -115,6 +123,32 @@ function createEntityForConnection() {
},
});
}
// Create a flower barrel.
function createFlowerBarrelEntity(position) {
const entity = createEntity();
return entity.fromJSON({
traits: {
pictured: {
params: {
images: {
initial: {
offset: [0, -32],
uri: '/flower-barrel.png',
},
}
},
},
existent: {},
graphical: {},
positioned: {
state: {
x: position[0],
y: position[1],
},
},
},
});
}
// Main loop.
let lastTime = performance.now();
function createMainLoop(avocadoServer) {