Here is my code, it does not fully work, but I could not figure out the bugs.
'If els' statments help control the flow of the code and make it more readble.
Conditionals are placed in between the parenthesis following the word 'if'.
let bug = [];
function setup() {
createCanvas(900,700);
strokeWeight(2);
}
function draw(){
noStroke();
background(0);
fill(0,20,17);
ellipse(130,320,140,440);
fill(1,50,32);
ellipse(50,330,130,440);
fill(1,31,27);
ellipse(120,360,130,400);
fill(11,7,1);
rect(110,560,10,50);
rect(120,560,10,50);
rect(45,550,10,50);
fill(0,20,13);
rect(0,600,900,600);
for(let i in bug){
bug[i].show();
bug[i].flash();
bug[i].move();}
if(mouseIsPressed){
bug.push(new Bug(mouseX,mouseY));}
}
function Bug(XPOS,YPOS){
this.initial_x = XPOS;
this.initial_y = YPOS;
this.x = 0;
this.y = 0;
this.seedx = random(0,1000);
this.seedy = random(0,1000);
this.yellow = color(255,255,10)
this.fade = 100;
this.show = function(){
stroke(255,255,10,this.fade);
point(this.x,this.y);}
this.move = function(){
this.x = this.initial_x+ map(noise(this.seedx), 0 , 1 , -100 , 100)
this.y = this.initial_y+ map(noise(this.seedy), 0 , 1 , -100 , 100)}
this.flash = function(){
this.fade = map( sin(this.seedx + frameCount*0.15), -1, 1, 0, 255);}