xxxxxxxxxx
116
function setup() {
createCanvas(400, 800);
}
// let beardX = 75;
// let beardY = 125;
let ballX = 200;
let ballY = 100;
let xDir = 2;
let vel = 0;//face velocity
let fX = 100;//face x-value
function draw() {
//print(mouseX, mouseY)
background('cyan');//blue for the sky
fill(255,204,165); //skin colour
fX = fX + vel;//updating value based on face velocity
ellipse(fX-48, 100, 10, 20); //left ear
//ellipse(53, 100, 4, 8); //ear 2nd layer
ellipse(fX+48, 100, 10, 20); //right ear
quad(fX-20, 150, fX+20, 150, 120, 182, 80, 182);//neck
ellipse(fX, 100, 90, 110); //face
ellipse(28,335,22);//left hand
ellipse(172,335,22);//right hand
arc(fX-23,128,15,16,radians(155),radians(205),OPEN);//dimple on right cheek
stroke(210,0,20); //red for mouth
strokeWeight(4); //thickness for mouth
arc(fX, 93, 80, 90, radians(60), radians(120), OPEN); //mouth
stroke(0);//changing colour back to black
strokeWeight(1); //default
fill(0);//black fill
rect(fX-43, 75, 8, 20);//left sideburn
rect(fX+35, 75, 8, 20);//right sideburn
triangle(fX, 155, fX-1, 153, fX+1, 153);//chin
arc(fX, 100, 95, 115, radians(210), radians(330), CHORD);//hair
fill(255);//white fill
ellipse(fX-20, 95, 20, 15);//left eye
ellipse(fX+20, 95, 20, 15);//right eye
fill(0);//black
ellipse(fX-20,95, 11,13);//left iris
ellipse(fX+20,95, 11,13);//right iris
fill('orange');//t-shirt colour
stroke('orange');
quad(20,182,41,182,36,325,20,325);//left sleeve
quad(180,182,159,182,164,325,180,325);//right sleeve
//found quad function online in the reference, which works like triangle, i.e., just needs the co-ordinates of the 4 points
rect(40,182,120,145);//t-shirt
fill(255,204,165);//skin colour
stroke(0);
triangle(fX, 100, fX-5, 120, fX+5, 120);//nose
arc(100,181, 40, 30,0, PI);//collarbone?
fill('blue');//shoe colour
stroke('blue');
ellipse(140,517,55,30);//right shoe
ellipse(60,517,55,30);//left shoe
stroke('cyan');
fill('cyan');//same colour as background
arc(140,517,56,30,radians(160),radians(200),CHORD);//cutting off the heel
arc(60,517,56,30,radians(340),radians(20),CHORD);
stroke('green');//grass colour
fill('green');
rect(0,530,400,400);//grass
stroke(0);
fill(0);//pant colour
quad(43,327,101,327,90,505,43,505);//left leg
quad(157,327,99,327,110,505,157,505);//right leg
stroke('brown');
fill('brown');//for sling bag
quad(22,182, 27,182,157,350,157,355);//strap
rect(157,350,23,50);//bag
stroke('yellow');//for the sun
fill('yellow');
ellipse(400,0,200);//Sun
stroke(0);//black outline for rugby ball
fill(247);//white
ellipse(ballX,ballY,98,70);//rugby ball
arc(ballX, ballY, 98, 30, PI, 0); //seam of the ball
arc(ballX, ballY, 98, 58, 0, PI); //second seam
ballX = ballX + xDir;
if ((ballX > width - 49)||(ballX < fX + 94)) {
xDir = -xDir;
}
if(ballX < fX + 94) {
vel = -1
}
if (fX < 95) {
vel = 1
}
if (fX > 100) {
vel = 0
fX=100
}
// point(beardX, beardY+1);//moustache
// point(beardX+1, beardY-1)
// beardX = beardX + 2;
// if (beardX>125){
// noLoop()
// }
}