diff --git a/resource/flower-barrel.png b/resource/flower-barrel.png new file mode 100644 index 0000000..8fbf28c Binary files /dev/null and b/resource/flower-barrel.png differ diff --git a/server/game.js b/server/game.js index 3641f33..638d215 100644 --- a/server/game.js +++ b/server/game.js @@ -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) {