#!/bin/env -S deno run --allow-net --allow-read import { log_from, v2, wait } from "../common/utils.ts"; import { Engine } from "./engine.ts"; import { Session } from "./entities/player.ts"; import { sys_spawn_obstacle, sys_spawn_structure } from "./components/world.ts"; import { Gateway } from "./network.ts"; import { sys_spawn_enemy } from "./entities/enemy.ts"; import { spiral } from "../common/utils.ts"; const log = log_from(import.meta); async function main() { log("Starting."); const engine = new Engine(); engine.start(); engine.run(await sys_spawn_structure("../data/structures/houses.txt", v2(2, 2))); engine.run(sys_spawn_enemy(v2(1, 1))); (async () => { await wait(5_000); for (const pos of spiral(v2(-8, -8))) { await wait(500); engine.run(sys_spawn_obstacle(pos, "@@")); } })(); const port = 9999; const gateway = new Gateway(port); log("Awaiting connection."); for await (const client of gateway.accept()) { Session.init(client, engine).start(); } } if (import.meta.main) await main();