From 3d2dcf24a0877335fd560fe2bbbe2f8098d80451 Mon Sep 17 00:00:00 2001 From: neki-dev Date: Fri, 25 Aug 2023 15:07:16 +0300 Subject: [PATCH] Added demo --- README.md | 10 ++++++++++ demo/index.html | 4 ++++ demo/src/index.ts | 5 ++++- demo/src/interface.ts | 1 + src/city.ts | 1 - src/utils.ts | 2 +- 6 files changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 84c20df..7819018 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,14 @@ Procedural city generation . +* ### [Demo](https://gen-city.neki.guru/) + +* ### Install + +```sh +npm i gen-city +``` + +. + TODO... \ No newline at end of file diff --git a/demo/index.html b/demo/index.html index 6a1ef8f..dad582f 100644 --- a/demo/index.html +++ b/demo/index.html @@ -57,6 +57,10 @@ +
+ + +
diff --git a/demo/src/index.ts b/demo/src/index.ts index 88ad69a..207e416 100644 --- a/demo/src/index.ts +++ b/demo/src/index.ts @@ -100,9 +100,12 @@ function generateAndRenderCity() { } drawPaths(); - drawNodes(); drawBuildings(); + if (ui.inputs.nodeDisplay?.checked) { + drawNodes(); + } + ui.screen.addEventListener("click", (event: MouseEvent) => { const position = { x: Math.floor(event.offsetX / tileSize), diff --git a/demo/src/interface.ts b/demo/src/interface.ts index 6267f55..d24d812 100644 --- a/demo/src/interface.ts +++ b/demo/src/interface.ts @@ -1,6 +1,7 @@ export const ui = { screen: document.getElementById('screen') as HTMLCanvasElement, inputs: { + nodeDisplay: document.querySelector('[name=nodeDisplay]'), seedMode: document.querySelector('[name=seedMode]'), streetMinLength: document.querySelector('[name=streetMinLength]'), worldWidth: document.querySelector('[name=worldWidth]'), diff --git a/src/city.ts b/src/city.ts index 59c08df..8ef02f9 100644 --- a/src/city.ts +++ b/src/city.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-new */ import { Path } from './path'; import { Node } from './node'; import { diff --git a/src/utils.ts b/src/utils.ts index 33bcfca..ca38e6e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,4 @@ -// eslint-disable-next-line import/no-cycle +/* eslint-disable import/no-cycle */ import { Point2D } from './types'; export function randomChance(value: number) {