Buff Queen AKA "Ez egy fa?"

Because the first placeholder player model
resembled a queen that's been to the gym a
bit too much. Also, before she got her head
and hands, she looked like a tree, legit.
This commit is contained in:
2024-12-21 23:46:01 +09:00
commit 2957903cb1
15 changed files with 1509 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
import { System } from 'detect-collisions'
import { EventEmitter } from 'node:events'
export default class Game {
entities = []
tickRate = 30
currentTick = 0
#eventEmitter = new EventEmitter()
#system = new System()
#tickBudget = Math.floor(1000 / this.tickRate)
get eventEmitter() { return this.#eventEmitter }
get system() { return this.#system }
spawn_entity(entity) {
this.entities.push(entity)
this.#system.insert(entity.collider)
}
async start() {
const start = performance.now()
await this.update()
setTimeout(() => this.start(), Math.max(0, this.#tickBudget - (performance.now() - start)))
}
async update() {
Promise.allSettled(this.entities.map((e) => e.update()))
this.currentTick++
this.eventEmitter.emit('tick')
}
}