change(player): tune shake animation

This commit is contained in:
nick-delirium 2023-02-13 14:39:19 +01:00
parent b84c1ccc8e
commit 5c87872c17

View file

@ -59,19 +59,26 @@ export default class Cursor {
setTimeout(() => this.isMoving = false, 60)
}
setDefaultStyle() {
this.cursor.style.width = 18 + 'px'
this.cursor.style.height = 30 + 'px'
this.cursor.style.transition = 'top .125s linear, left .125s linear'
}
shake(iteration = 1, upwards = true, original: { x: number, y: number } = this.coords) {
if (this.isMoving) return;
if (this.isMoving) {
return this.setDefaultStyle()
}
if (iteration < 10) {
this.cursor.style.transition = 'top .06s linear, left .06s linear'
this.cursor.style.width = 45 + 'px'
this.cursor.style.height = 75 + 'px'
const shift = upwards ? 60 : -60
const shift = upwards ? 90 : -90
this.move({ x: this.coords.x + shift, y: this.coords.y - shift })
setTimeout(() => this.shake(iteration + 1, !upwards, original), 60)
} else {
this.cursor.style.width = 18 + 'px'
this.cursor.style.height = 30 + 'px'
this.move(original)
this.setDefaultStyle()
return this.move(original)
}
}