//Lydia Jin
//Section B
//jialuj@andrew.cmu.edu
// Project 5
var flag = false;
function setup() {
createCanvas(600, 600); //setup canvas
background('black');
}
function draw() {
for (var y = 50; y<=550; y+=100){
//iterate loop for rows until hits botton
if (flag == false){
//use a boolean to alternate between two sets of shape
for (var x = 0; x<522; x+=30){ //iterate set A for columns
if (x==0){
//draw a PAC MAN at each beginning of the iteration
fill('yellow');
noStroke();
arc(50, y, 50, 50, QUARTER_PI*0.7, -QUARTER_PI*0.7);
}
noStroke();
fill(random(255), random(255),random(255)); //random color of the dots
ellipse(x+80, y, 8); //draw the PAC-dots
}
flag = true;
//change the state of boolean
}
else{
for (var x = 600; x>78; x-=30){
//to iterate the another set of shape
if (x==600){
//draw a PAC MAN at each beginning of the iteration
fill('yellow');
noStroke();
arc(550, y, 50, 50, PI + QUARTER_PI*0.7, PI -QUARTER_PI*0.7);
}
noStroke();
fill(random(255), random(255),random(255)); //random color of the dots
ellipse(x-80, y, 8); //draw the PAC-dots
}
flag=false;
//change the state of boolean
}
}
noLoop();//Stop all loops, make static wallpaper
}
At first, I wanted random PAC MANs to appear in every row. But later on I decided to make it look more dynamic by putting in the beads along with the Pac Man to make the wallpaper more colorful. This would be a cool wall paper for a kid’s bedroom. 🙂