35 lines
		
	
	
		
			No EOL
		
	
	
		
			975 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			No EOL
		
	
	
		
			975 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
// Particle class (for explosion)
 | 
						|
export class Particle {
 | 
						|
    constructor(x, y, color) {
 | 
						|
        this.x = x;
 | 
						|
        this.y = y;
 | 
						|
        this.velocityX = (Math.random() - 0.5) * 5;
 | 
						|
        this.velocityY = (Math.random() - 0.5) * 5;
 | 
						|
        this.size = Math.random() * 4 + 1; // Tamanho maior para melhor visibilidade
 | 
						|
        this.color = color;
 | 
						|
        this.alpha = 1;
 | 
						|
        this.gravity = 0.05;
 | 
						|
        this.resistance = 0.96;
 | 
						|
    }
 | 
						|
 | 
						|
    update() {
 | 
						|
        this.velocityX *= this.resistance;
 | 
						|
        this.velocityY *= this.resistance;
 | 
						|
        this.velocityY += this.gravity;
 | 
						|
 | 
						|
        this.x += this.velocityX;
 | 
						|
        this.y += this.velocityY;
 | 
						|
        this.alpha -= 0.01;
 | 
						|
 | 
						|
        return this.alpha > 0;
 | 
						|
    }
 | 
						|
 | 
						|
    draw(context) {
 | 
						|
        context.globalAlpha = this.alpha;
 | 
						|
        context.fillStyle = this.color;
 | 
						|
        context.beginPath();
 | 
						|
        context.arc(this.x, this.y, this.size, 0, Math.PI * 2);
 | 
						|
        context.fill();
 | 
						|
        context.globalAlpha = 1;
 | 
						|
    }
 | 
						|
} 
 |