()
| 30 | } |
| 31 | |
| 32 | update() { |
| 33 | if (!isDragging || dragParticle !== this) { |
| 34 | this.x += this.speedX; |
| 35 | this.y += this.speedY; |
| 36 | |
| 37 | // Bounce off the edges of the canvas |
| 38 | if (this.x < 0 || this.x > canvas.width) { |
| 39 | this.speedX *= -1; |
| 40 | } |
| 41 | if (this.y < 0 || this.y > canvas.height) { |
| 42 | this.speedY *= -1; |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | draw() { |
| 48 | ctx.beginPath(); |