rawJSON = loadJSON("https://www.openprocessing.org/api/sketch/"+name[12]+name[13]+name[14]+name[15]+name[16]+name[17]+"/true");
createCanvas(windowWidth, windowHeight);
balls.push(new Ball(random(width),random(height)))
var thumb_txt="Coronavirus Game"
var colors=['#ff0000','#ffa500','#ffff00','#008000','#0000ff','#4b0082','#ee82ee','#F60000','#FF8C00','#FFEE00','#4DE94C','#3783FF','#4815AA']
text("healthy\ninfected\nrecovered\ndead",w-100,h)
text("draw lines to isolate the infected",w+150,h-150)
text("space to erase lines",w+150,h+100)
line(w+150,h-130,w+150,frameCount%(200)+h-130)
if(hit(mouseX,mouseY,0,0,w-25,400,50,30)&&mouseIsPressed){home=1}
for (let i=0; i< lines.length;i++){
if(dist(mouseX,mouseY,lines[i].x,lines[i].y)<40&&keyIsDown(32)){lines.splice(i,1);i--}
for (let i=0; i< balls.length;i++){
for (let j=0; j<balls.length;j++){
let d=dist(balls[i].x,balls[i].y,balls[j].x,balls[j].y)
if(d<20&&i!==j){if(balls[i].inf&&!balls[j].inf&&round(random(50))==1 && (!balls[j].mask || random() < 0.7) && (!balls[i].mask || random() < 0.3)){balls[j].inf=true}}
if(d<20&&i!==j){if(balls[j].inf&&!balls[i].inf&&round(random(50))==1 && (!balls[j].mask || random() < 0.3) && (!balls[i].mask || random() < 0.7)){balls[i].inf=true}}
if(keyIsDown(32)){x=0;y=0}
if(get(x+xspeed*2,y)[0]==0){xspeed=-xspeed}
if(get(x,y+yspeed*2)[0]==0){yspeed=-yspeed}
if (frameCount % 10 == 0) {
lines.push(new Line(noise((frameCount)/100)*width * 2 - width/2,noise((frameCount)/200)*height,noise((frameCount - 10)/100)*width * 2 - width/2,noise((frameCount - 10)/200)*height))
lines.push(new Line(noise((frameCount + 95842767)/100)*width * 2 - width/2,noise((frameCount + 4183584386)/200)*height,noise((frameCount + 95842767 -10)/100)*width * 2 - width/2,noise((frameCount + 4183584386 - 10)/200)*height))
lines.push(new Line(noise((frameCount + 4952858777)/100)*width * 2 - width/2,noise((frameCount + 132569825462)/200)*height,noise((frameCount + 4952858777 - 10)/100)*width * 2 - width/2,noise((frameCount + 132569825462 - 10)/200)*height))
rect(width/2,height/2-200,thumb_txt.length*40,100,20)
text(thumb_txt,width/2,height/2-200)
textAlign(CENTER,CENTER);
if(mouseY>height-50){fill(999)
rect(0,height-50,width,50)
function hit(x1,y1,w1,h1,x2,y2,w2,h2){
return(x1+w1>x2&&x1<x2+w2&&y1+w1>y2&&y1<y2+h2)
function Line (xx,yy,px,py) {
this.tt=round(random(2000,3000))
if(round(random(0,30))==1){
this.inf=true}else{this.inf=false}
if(this.t>180){ this.r=round(random(3));this.t=0}
if(get(this.x+this.xspeed*2,this.y)[0]==0){this.xspeed=-this.xspeed}
if(get(this.x,this.y+this.yspeed*2)[0]==0){this.yspeed=-this.yspeed}
this.xspeed+=random(-0.1,0.1)
this.yspeed+=random(-0.1,0.1)
if(this.show){fill(255,128,0); if (random() < 0.01 && (this.inf || random() < 0.01)) {this.positive = true}}else{fill(0,255,0); if (random() < 0.0001) {this.show = true}}
if(this.positive){fill(255, 0,0);}
if(this.inf){this.tt--; if (random() < 0.001) {this.show = true}}
if(this.tt<=0){this.tt=round(random(2000,3000));this.inf=false; this.positive = false; this.show = false}
if (random(1000000) < frameCount) {
if(this.mask) {strokeWeight(5)} else {noStroke()}
if(this.inf&&random() < 0.0001&&this.tt<2000){this.dead=true;balls.push(new Ball(random(width),random(height)))}
if(this.dead){this.movee=false;fill(0)}
ellipse(this.x,this.y,20)