xxxxxxxxxx
50
let mySound;
function preload() {
soundFormats('m4a');
mySound = loadSound('gun');
}
let counter = 0;
function setup() {
outputVolume(0.1);
pixelDensity(1);
createCanvas(400, 400);
background(0);
fill('red')
rect(20, 20, width-40, height-40)
frameRate(10);
}
function shoot() {
mySound.play();
stroke('black')
fill('black')
let centerX = random(width)
let centerY = random(height)
let deviation = 25;
let gauge = 8;
let gaugeDeviation = 5;
for (let x = 0; x < 30; x++) {
circle(centerX + randomGaussian(0, deviation), centerY + randomGaussian(0, deviation), random(gauge - gaugeDeviation, gauge + gaugeDeviation))
}
}
function draw() {
counter++;
if (counter > 20) {
counter = 0;
shoot()
}
}