Hi! Thanks for your suggestions. That does make sense, but I’m not sure how to fix the problem or go about it a different way. Here is my code:
//strobe variable
var strobe = 10;
//image variables
var img_out;
var img_dan;
var img_east;
var img_po;
var img_path;
//sound variables
var sound_po;
var sound_out;
function preload() {
img_out = loadImage(“outkast.jpeg”);
img_dan = loadImage(“danger.jpeg”);
img_east = loadImage(“east_point.png”);
img_po = loadImage(“police.jpeg”);
img_path = loadImage(“path.jpeg”);
sound_po = loadSound(“police_siren.mp3”);
sound_out = loadSound(“outkast_short.mp3”);
}
function setup() {
createCanvas(700, 600);
}
function draw() {
noFill();
strokeWeight(4);
var c = (‘rgba(255, 255, 0, 255)’);
background©;
//police siren
if (mouseX > 50 && mouseX <300){
sound_po.play();
} else {
sound_po.stop();
}
//outkast
if (mouseX > 600 && mouseX <700){
sound_out.play();
} else {
sound_out.stop();
}
//background color change near police car
if (mouseX > 50 && mouseX <250) {
c = (‘rgba(255, 0, 0, 100)’);
background©;
}
//police car
var expandX = map(pmouseX, 0, 322, 280, 360 );
var expandY = map(mouseY, 0, 156, 130, 180);
if (mouseY <300 && mouseX < 400) {
image(img_po, 10, 10, expandX, expandY);
} else {
image(img_po, 10, 10, 322, 156);
}
//strobing circles
strobe = strobe + 10;
if (mouseX > 50 && mouseX <300) {
ellipse(width/2, height/2, strobe, strobe);
}
if (strobe > height&&width ) {
strobe = 10;
}
image(img_out, 390, 10);
image(img_dan, 400, 400);
image(img_east, 250, 200);
image(img_path, 10, 330);
}
Now that I understand the issue, I will try different things.
Thanks again.