diff --git a/public/index.html b/public/index.html
index 02a9c97..192bf27 100644
--- a/public/index.html
+++ b/public/index.html
@@ -22,6 +22,7 @@
html, body {
margin: 0;
padding: 0;
+ user-select: none;
}
.debug-panel {
diff --git a/public/main.js b/public/main.js
index db2de84..524ba2c 100644
--- a/public/main.js
+++ b/public/main.js
@@ -20,7 +20,7 @@ scene.add(ground)
global.camera = camera
global.scene = scene
-camera.position.set(0, -100, 200)
+camera.position.set(0, -250, 500)
camera.rotation.set((30 / 180) * Math.PI, 0, 0)
// camera.lookAt(0, 0, 0)
diff --git a/src/entity.js b/src/entity.js
index b7e6b29..92d4af0 100644
--- a/src/entity.js
+++ b/src/entity.js
@@ -4,6 +4,7 @@ import Victor from 'victor'
export default class Entity {
id = crypto.randomUUID()
pos = new Victor(0, 0)
+ speed = 280
radius = 0
#collider = null
#dest = null
@@ -24,9 +25,10 @@ export default class Entity {
}
async takeStep() {
+ const speed = this.speed / (this.game?.tickBudget ?? 1000)
if (this.#dest != null) {
- this.pos.add(this.#dest.clone().subtract(this.pos).normalize())
- if (this.pos.clone().subtract(this.#dest).length() <= 1) {
+ this.pos.add(this.#dest.clone().subtract(this.pos).normalize().multiplyScalar(speed))
+ if (this.pos.clone().subtract(this.#dest).length() <= speed) {
this.pos = this.#dest
this.#dest = null
}
diff --git a/src/game.js b/src/game.js
index 9f4276b..4f0effb 100644
--- a/src/game.js
+++ b/src/game.js
@@ -12,10 +12,12 @@ export default class Game {
get eventEmitter() { return this.#eventEmitter }
get system() { return this.#system }
+ get tickBudget() { return this.#tickBudget }
spawn_entity(entity) {
this.entities.push(entity)
this.#system.insert(entity.collider)
+ entity.game = this
}
async start() {