diff --git a/src/index.js b/src/index.js index eee13a1..fa2fa24 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,4 @@ -import { Dungeon } from './level.js' +import * as LEVEL from './level.js' import { WebSocketExpress } from 'websocket-express' import express from 'express' import Game from './game.js' @@ -35,6 +35,7 @@ app.ws('/ws', async (req, res) => { console.info(message) if (message.action == 'entities') { websocket.send(JSON.stringify({ entities: game.entities.map((it) => it.id) })) + return } if (message.action == 'join') { @@ -64,5 +65,6 @@ app.ws('/ws', async (req, res) => { app.listen(port, () => { console.info({ event: 'startup', visit: `http://localhost:${port}/menu/` }) - Dungeon.scenario(game) + LEVEL.Chase.scenario(game) + game.start() }) diff --git a/src/level.js b/src/level.js index fc65fad..caf49cb 100644 --- a/src/level.js +++ b/src/level.js @@ -26,8 +26,24 @@ export class Dungeon { game.spawnEntity(new Entity(Template.player({ id: '2', spawnPosition: new Vector2(1500, 700), team, dead: true }))) game.spawnEntity(new Entity(Template.basilisk({ id: 'boss', spawnPosition: new Vector2(2200, 750), team: Team.neutral }))) + } +} - game.start() +export class Chase { + static scenario(game) { + game.width = 1000 + game.height = 1000 + + const chaserTemplate = { + // TODO: TODO + } + + const runnerTemplate = { + // TODO: TODO + } + + game.spawnEntity(new Entity({ ...chaserTemplate })) + game.spawnEntity(new Entity({ ...runnerTemplate })) } } @@ -47,9 +63,6 @@ export class Zigzag { new Vector2(i + 100, game.height - lowest), ])) } - - - game.start() } } @@ -68,8 +81,6 @@ export class Ravine { team, }))) } - - game.start() } static logic() { const game = this