add minimap
This commit is contained in:
+2
-2
@@ -61,8 +61,8 @@ export default class Entity {
|
||||
const speed = this.speed / (this.game?.tickBudget ?? 1000)
|
||||
if (this.#dest != null) {
|
||||
const fixedDest = new THREE.Vector2(
|
||||
Math.min(Math.max(this.radius, this.#dest.x), this.game?.width ?? Infinity),
|
||||
Math.min(Math.max(this.radius, this.#dest.y), this.game?.height ?? Infinity),
|
||||
Math.min(Math.max(this.radius, this.#dest.x), (this.game?.width ?? Infinity) - this.radius),
|
||||
Math.min(Math.max(this.radius, this.#dest.y), (this.game?.height ?? Infinity) - this.radius),
|
||||
)
|
||||
|
||||
const distance = this.position.clone().sub(fixedDest).length()
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@ import { EventEmitter } from 'node:events'
|
||||
export default class Game {
|
||||
tickRate = 30
|
||||
currentTick = 0
|
||||
width = 15000
|
||||
height = 15000
|
||||
width = 1000
|
||||
height = 1000
|
||||
|
||||
#entities = []
|
||||
#eventEmitter = new EventEmitter()
|
||||
|
||||
+2
-2
@@ -41,13 +41,13 @@ app.listen(port, () => {
|
||||
|
||||
const entity = new Entity()
|
||||
entity.id = '1'
|
||||
entity.teleport(0, 0)
|
||||
entity.teleport(100, 100)
|
||||
entity.radius = 35
|
||||
game.spawn_entity(entity)
|
||||
|
||||
const entity2 = new Entity()
|
||||
entity2.id = '2'
|
||||
entity2.teleport(100, 100)
|
||||
entity2.teleport(200, 100)
|
||||
entity2.radius = 35
|
||||
game.spawn_entity(entity2)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user