move rotationPoint4Used test to rotation

This commit is contained in:
Adrien MALINGREY 2024-10-01 00:49:38 +02:00
parent af9e0c481a
commit f7b7b74e01

View File

@ -260,13 +260,12 @@ class Tetromino extends THREE.Group {
return this.minoesPosition[facing].every(minoPosition => this.parent?.cellIsEmpty(minoPosition.clone().add(testPosition))) return this.minoesPosition[facing].every(minoPosition => this.parent?.cellIsEmpty(minoPosition.clone().add(testPosition)))
} }
move(translation, rotatedFacing, rotationPoint) { move(translation, rotatedFacing) {
if (this.canMove(translation, rotatedFacing)) { if (this.canMove(translation, rotatedFacing)) {
this.position.add(translation) this.position.add(translation)
this.rotatedLast = rotatedFacing this.rotatedLast = rotatedFacing
if (rotatedFacing != undefined) { if (rotatedFacing != undefined) {
this.facing = rotatedFacing this.facing = rotatedFacing
if (rotationPoint == 4) this.rotationPoint4Used = true
} }
if (this.canMove(TRANSLATION.DOWN)) { if (this.canMove(TRANSLATION.DOWN)) {
this.locking = false this.locking = false
@ -288,9 +287,12 @@ class Tetromino extends THREE.Group {
rotate(rotation) { rotate(rotation) {
let testFacing = (this.facing + rotation) % 4 let testFacing = (this.facing + rotation) % 4
return this.srs[this.facing][rotation].some( return this.srs[this.facing][rotation].some((translation, rotationPoint) => {
(translation, rotationPoint) => this.move(translation, testFacing, rotationPoint) if (this.move(translation, testFacing)) {
) if (rotationPoint == 4) this.rotationPoint4Used = true
return true
}
})
} }
get tSpin() { get tSpin() {