add client side terrain without collision

This commit is contained in:
2024-12-23 11:57:36 +09:00
parent 604368b52c
commit ba0d8f606a
6 changed files with 107 additions and 9 deletions
+4 -4
View File
@@ -1,4 +1,4 @@
import * as THREE from 'three'
import { Vector2 } from 'three'
import SAT from 'sat'
import SATX from './satx.js'
@@ -7,7 +7,7 @@ export default class Entity {
speed = 400
radius = 0
#position = new THREE.Vector2(0, 0)
#position = new Vector2()
#dest = null
#game = null
@@ -40,7 +40,7 @@ export default class Entity {
}
moveAction(x, y) {
this.#dest = new THREE.Vector3(x, y, 0)
this.#dest = new Vector2(x, y)
}
state() {
@@ -60,7 +60,7 @@ export default class Entity {
takeStep() {
const speed = this.speed / (this.game?.tickBudget ?? 1000)
if (this.#dest != null) {
const fixedDest = new THREE.Vector2(
const fixedDest = new Vector2(
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),
)