Use left, right, and down arrows to move the ball, use "k" to move the girl on the right!
xxxxxxxxxx
//global variable space
let skirtArray;
let i;
let x;
function setup() {
createCanvas(400, 400);
list=list= [color(125,52,235), color(32, 100, 179), color(125,52,235)];
//variables
skirtArray=[color(0,0,0), color(242, 196, 29), color(242, 196, 29)];
i=0;
ballX = 295;
ballY=300;
armX=302;
armY=248;
x = 0;
}
function draw() {
background(random(list));
//hair
fill(0,0,0);
circle(60,185,50);
circle(335 + x,185,50);
fill(102,78,35);
rect(333+x,160,3,11);
//face
fill(102,78,35);
stroke(255,255,255);
strokeWeight(0);
circle(60,195,48);
circle(335+x,195,48);
//lips
fill(179, 39, 11);
circle(60,205,10);
fill(168, 50, 127);
circle(335+x,205,10);
//pineapple hair
fill(0,0,0)
circle(45,150,32);
circle(70,150,32);
circle(42,130,32);
circle(69,128,32);
circle(55,125,32);
// afro puffs
fill(0,0,0);
stroke(102,78,35);
circle(320+x,148,40);
circle(350+x,148,40);
///neck
fill(102,78,35);
rect(48,210,25,14);
rect(325+x,210,25,14);
//shirts
fill(179, 39, 11);
rect(38, 223,50, 65, 10);
rect(24,224,25,30,10);
rect(75,224,25,30,10);
fill(168, 50, 127);
rect(315+x,223,50, 65,10);
rect(355+x,223,25,30,10);
rect(300+x,223,25,30,10);
//legs & arms
fill(102,78,35);
rect(40,319,15,45);
rect(70,319,15,45);
rect(320+x,320,15,45);
rect(345+x,320,15,45);
rect(25,248,15,45);
rect(85,248,15,45);
rect(365+x,248,15,45);
rect(armX,armY,15,45);
// bottoms& shoes
fill(i);
rect(37,270,52,50,10);
fill(255,255,255);
rect(315+x,279,52,50,10);
circle(78,370,15);
circle(48,370,15);
circle(328+x,370,15);
circle(353+x,370,15);
//ball
fill(255,255,255);
circle(ballX,ballY,40);
//ground
fill(66, 145, 13);
rect(300,380,400,40);
rect(200,380,400,40);
rect(100,380,400,40);
rect(0,380,400,40);
}
//interactive functions
function mousePressed(){
i=random(skirtArray);
}
function keyPressed(){
if(keyCode==LEFT_ARROW){
ballX-=5;
}
if(keyCode==RIGHT_ARROW){
ballX+=5;
}
if(keyCode==DOWN_ARROW){
ballX+=5;
}
if(key==='k') {
armX-=5;
x-=5;
}
}