For my Final code project I intend on making a pac-man opening and closing it's mouth while moving vertically across the canvas. In order to make this code I have to input two different forms of pac-man: pac-man 1 and pac-man 2, pac-man 1 is the arc missing a piece. pac-man 1 acts as the open mouth and pac-man 2 is the filled in ellipse acting as the closed mouth pac-man. In order to get pac-man 1 to shift vertically across the canvas I put in a for loop that shifts pac-man 1 70 pixels to the right. Next I translated pac-man 2 to sit in the middle of the redrawn pac-man 1 to create the opening and closing mouth effect before I add in the frame rate to move the both pac-men vertically across the screen. when My code is fully finished I expect that the code will take different shifts to draw pac-man 1 and then 2 over and over with a time high speed frame rate to imitate the open and closed mouth motion of pac-man.
function setup() {
createCanvas(400, 400);
frameRate(80)
}
function draw() {
background(220);
//(Pac man 1 color: yellow)
//pacman();
for (var j = 70; j <= 210; j += 70) {
pacman();
}
//for (var i = 70; i <= 210; i += 70) {
translate(-15, 0);
pacman2();
//}
}
function pacman() {
fill(255, 255, 110);
for (var j = 70; j <= 210; j += 70) {
arc(j, 100, 80, 80, 0, (PI + QUARTER_PI) + HALF_PI, PIE);
}
}
function pacman2() {
fill(255, 255, 110);
ellipse(155, 100, 80, 80);
}