add tweening
This commit is contained in:
+9
-1
@@ -72,6 +72,10 @@ export default class Entity {
|
||||
return entityColliders.concat(terrainColliders)
|
||||
}
|
||||
|
||||
fixPosition() {
|
||||
this.#position = SATX.fixCollisions(this.#position, this.collidables(), this.radius, this.game?.width, this.game?.height)
|
||||
}
|
||||
|
||||
isColliding(...colliders) {
|
||||
return SATX.collideObjects(this.collider, colliders)
|
||||
}
|
||||
@@ -91,9 +95,12 @@ export default class Entity {
|
||||
}
|
||||
|
||||
teleport(x, y) {
|
||||
this.position.set(x, y)
|
||||
const position = SATX.fixCollisions(new Vector2(x, y), this.collidables(), this.radius, this.game?.width, this.game?.height)
|
||||
this.position.set(position.x, position.y)
|
||||
}
|
||||
|
||||
// TODO: unset destination on teleports, etc.
|
||||
// TODO: recalculate path on obstructions (currently next waypoint is used)
|
||||
takeStep(distanceTraveled = 0) {
|
||||
const speed = (this.speed / (this.game?.tickBudget ?? 1000)) - distanceTraveled
|
||||
const collidables = this.collidables()
|
||||
@@ -140,6 +147,7 @@ export default class Entity {
|
||||
|
||||
update() {
|
||||
this.takeStep()
|
||||
this.fixPosition()
|
||||
}
|
||||
|
||||
waypoints() {
|
||||
|
||||
Reference in New Issue
Block a user