| 422 | } |
| 423 | |
| 424 | stepPos(x, duration) { |
| 425 | let n = 0; |
| 426 | const sqrt2 = Math.sqrt(2); |
| 427 | for (let i = 1; i <= this.STEP; i++) { |
| 428 | n += 1 / i; |
| 429 | } |
| 430 | for (let i = 0; i < this.STEP; i++) { |
| 431 | x = this.puzzleX / (n * (i + 1)); |
| 432 | const currX = parseInt((Math.random() * 30 - 15) + x, 10); |
| 433 | const currY = parseInt(Math.random() * 7 - 3, 10); |
| 434 | const currDuration = parseInt((Math.random() * 0.4 + 0.8) * duration, 10); |
| 435 | |
| 436 | this.moveToAndCollect({ |
| 437 | x: currX, |
| 438 | y: currY, |
| 439 | duration: currDuration, |
| 440 | }); |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | fixPos() { |
| 445 | const actualX = this.pos[this.pos.length - 1][0] - this.pos[1][0]; |