add 3D casting indicator

This commit is contained in:
2025-01-18 21:02:04 +09:00
parent 7824ba976b
commit 0b949683a6
3 changed files with 35 additions and 22 deletions
+9
View File
@@ -18,6 +18,7 @@ export default class Entity {
memory = {} // TODO: hide from reports but keep public
position = null
radius = 0
rotation = 0
speed = 400
team = Team.neutral
visualRadius = null
@@ -102,6 +103,11 @@ export default class Entity {
this.#moving = false
}
const targetPosition = (cursor instanceof Vector2) ? cursor : this.game?.entities.find((it) => it.id == cursor)?.position
if (targetPosition instanceof Vector2) {
this.rotation = targetPosition.clone().sub(this.position).angle()
}
const cooldown = this.game?.secToTick(ability.cooldown) ?? 0
const lastCast = this.cooldowns[ability.id]
const timestamp = this.game?.currentTick ?? 0
@@ -399,10 +405,13 @@ export default class Entity {
const direction = difference.clone().normalize()
const stepTaken = this.position.clone().add(direction.multiplyScalar(speed))
const position = distance <= speed ? destination : stepTaken
const rotation = direction.angle()
const collider = Entity.collider(position.x, position.y, this.radius)
const isColliding = SATX.collideObjects(collider, this.collidables())
this.rotation = rotation
if (!isColliding) {
this.position.copy(position)
}
-12
View File
@@ -123,18 +123,6 @@ function laneScenario() {
}
}
game.logic = gameLogic
// player2.teleport(new Vector2(100, 100))
// player2.logic = function patrolLogic() {
// const entity = this
// if (entity.position.x < 100) { entity.memory.patrolReverse = false }
// if (entity.position.x > 1900) { entity.memory.patrolReverse = true }
// const goal = entity.memory.patrolReverse ? new Vector2(50, 100) : new Vector2(1950, 100)
// entity.moveAction(goal)
// }
// player1.abilities[0] = 'melee_attack'
}
app.listen(port, () => {