xxxxxxxxxx
196
var vx,vy;
var rand;
var wall1, wall2, wall3, wall4;
var stat1, stat2, stat3, stat4, stat5, stat6, stat7, stat8, stat9, stat10, stat11, stat12, stat13, stat14, stat15, stat16;
var ball1, ball2, ball3, ball4, ball5, ball6, ball7, ball8, ball9, ball10, ball11, ball12, ball13, ball14, ball15, ball16;
var balls = [];
function setup() {
createCanvas(600, 600);
rand = Math.round(random(1,16));
stat1 = "negative";
stat2 = "negative";
stat3 = "negative";
stat4 = "negative";
stat5 = "negative";
stat6 = "negative";
stat7 = "negative";
stat8 = "negative";
stat9 = "negative";
stat10 = "negative";
stat11 = "negative";
stat12 = "negative";
stat13 = "negative";
stat14 = "negative";
stat15 = "negative";
stat16 = "negative";
switch(rand){
case 1:
stat1 = "positive";
break;
case 2:
stat2 = "positive";
break;
case 3:
stat3 = "positive";
break;
case 4:
stat4 = "positive";
break;
case 5:
stat5 = "positive";
break;
case 6:
stat6 = "positive";
break;
case 7:
stat7 = "positive";
break;
case 8:
stat8 = "positive";
break;
case 9:
stat9 = "positive";
break;
case 10:
stat10 = "positive";
break;
case 11:
stat11 = "positive";
break;
case 12:
stat12 = "positive";
break;
case 13:
stat13 = "positive";
break;
case 14:
stat14 = "positive";
break;
case 15:
stat15 = "positive";
break;
case 16:
stat16 = "positive";
}
wall1 = new Wall(10,300,20,600);
wall2 = new Wall(300,10,600,20);
wall3 = new Wall(590,300,20,600);
wall4 = new Wall(300,590,600,20);
vx = random(-5,5);
vy = random(-5,5);
ball1 = new Ball(112.5,112.5,stat1,vx,vy,balls);
vx = random(-5,5);
vy = random(-5,5);
ball2 = new Ball(235,112.5,stat2,vx,vy,balls);
vx = random(-5,5);
vy = random(-5,5);
ball3 = new Ball(357.5,112.5,stat3,vx,vy,balls);
vx = random(-5,5);
vy = random(-5,5);
ball4 = new Ball(478,112.5,stat4,vx,vy,balls);
vx = random(-5,5);
vy = random(-5,5);
ball5 = new Ball(112.5,235,stat5,vx,vy,balls);
vx = random(-5,5);
vy = random(-5,5);
ball6 = new Ball(235,235,stat6,vx,vy,balls);
vx = random(-5,5);
vy = random(-5,5);
ball7 = new Ball(357.5,235,stat7,vx,vy,balls);
vx = random(-5,5);
vy = random(-5,5);
ball8 = new Ball(478,235,stat8,vx,vy,balls);
vx = random(-5,5);
vy = random(-5,5);
ball9 = new Ball(112.5,357.5,stat9,vx,vy,balls);
vx = random(-5,5);
vy = random(-5,5);
ball10 = new Ball(235,357.5,stat10,vx,vy,balls);
vx = random(-5,5);
vy = random(-5,5);
ball11 = new Ball(357.5,357.5,stat11,vx,vy,balls);
vx = random(-5,5);
vy = random(-5,5);
ball12 = new Ball(478,357.5,stat12,vx,vy,balls);
vx = random(-5,5);
vy = random(-5,5);
ball13 = new Ball(112.5,478,stat13,vx,vy,balls);
vx = random(-5,5);
vy = random(-5,5);
ball14 = new Ball(235,478,stat14,vx,vy,balls);
vx = random(-5,5);
vy = random(-5,5);
ball15 = new Ball(357.5,478,stat15,vx,vy,balls);
vx = random(-5,5);
vy = random(-5,5);
ball16 = new Ball(478,478,stat16,vx,vy,balls);
balls = [ball1, ball2, ball3, ball4, ball5, ball6, ball7, ball8, ball9, ball10, ball11, ball12, ball13, ball14, ball15, ball16];
}
function draw() {
background(136,255,120);
wall1.draw();
wall2.draw();
wall3.draw();
wall4.draw();
for (let a = 0; a < 15; a++){
balls[a].draw();
balls[a].move();
balls[a].colWall();
balls[a].colBall();
}
for (let i = 0; i < 15; i++) {
if(balls[i].corona === "positive"){
for (let z = 0; z < 15; z++) {
balls[i].infect(balls[z]);
}
}
}
}