xxxxxxxxxx
47
a = 0;
b = 0;
c = 0;
d = 0;
function setup() {
createCanvas(400, 400);
frameRate(243676034296920376);
}
function draw() {
background(0);
stroke(255);
line(200,200,mouseX,mouseY);
var x = ave(200,mouseX);
var y = ave(200,mouseY);
fill(a,b,c);
ellipse(x,y,d+30,d+30);
//challenge: use the ave function again to make
//a green dot half way between the center and the
//red dot
var x2 = ave(x,200);
var y2 = ave(y,200);
fill(b,c,a);
ellipse(x2,y2,d+30,d+30);
var x3 = ave(x,mouseX);
var y3 = ave(y,mouseY);
fill(c,a,b);
ellipse(x3,y3,d+30,d+30);
a = random (0,255);
b = random (0,255);
c = random(0,255);
if(keyIsDown(UP_ARROW)){
d = d + 1;
}
if(keyIsDown(DOWN_ARROW)){
d = d - 1;
}
if (d < -30){
d = -30;
}
}
function ave(num1, num2){
return (num1 + num2)/2
// replace with code to return average of the two arguments
}