Initially, I wanted to make a wallpaper that resembled Pacman. I approached the assignment by using for loops to create 2 sets of grids, the first was the dots that Pacman eats, and the second is the grid for the blue squares.
// Your name: Ashley Su
// Your andrew ID: ashleysu
// Your section (C):
function setup() {
createCanvas(450,590);
background('Black');
}
function dotGrid() {
var PADDING = 20;
var ROWS =19;
var COLUMNS =13;
var CELL_COLOR = 'Blue'
for (var col=0;col<COLUMNS;col++) {
for (var row=0;row<ROWS;row++) {
var left = PADDING+(col*34);
var top = PADDING+(row*34.3);
fill(random(255),random(255),random(255))
circle(left,top,10);
}
}
}
function blueBaracades() {
var PADDING = 40;
var ROWS = 4;
var COLUMNS = 3;
var CELL_SIZE = 140;
var CELL_COLOR = 'Blue'
fill(0);
stroke('Blue')
strokeWeight(3);
for (var col=0;col<COLUMNS;col++) {
for (var row=0;row<ROWS;row++) {
var left = PADDING+(col*CELL_SIZE);
var top = PADDING+(row*CELL_SIZE);
var size = CELL_SIZE - 50;
rect(left,top,size,size);
}
}
}
function pacmans(){
fill('yellow');
noStroke();
push()
translate(width/5,height/4+7);
rotate(radians(310));
arc(0,0,35,35,radians(80),radians(35)/2);
pop();
push();
translate(width/3*2,height/2);
rotate(radians(140));
arc(0,0,35,35,radians(80),radians(20)/2);
pop();
push();
translate(width/3+4,height-height/6);
rotate(radians(230));
arc(0,0,35,35,radians(80),radians(20)/2);
pop();
push();
translate(width-width/7,height-20);
rotate(radians(140));
arc(0,0,35,35,radians(80),radians(20)/2);
pop();
push();
translate(width-20,height/26);
rotate(radians(45));
arc(0,0,35,35,radians(80),radians(20)/2);
pop();
}
function draw(){
dotGrid();
blueBaracades();
pacmans();
noLoop();
}