xxxxxxxxxx
41
var boolDoRefresh;
var imgw, imgh;
let pinky;
let shrek;
function preload() {
pinky = loadImage('pinky.png');
shrek = loadImage('shrek.png');
}
function setup() {
createCanvas(600, 600);
boolDoRefresh = true;
imgw = 80;
imgh = 1.4 * imgw;
}
function draw() {
if (boolDoRefresh) {
background(255, 213, 0)
for(var i=0; i<=(width/imgw) + 1; i++) {
for(var j=0; j<=(height/imgh) + 1; j++) {
var img;
if(random() < 0.05) {
img = shrek;
} else {
img = pinky;
}
image(img, imgw*i - imgw/5,imgh*j - (i%2)*(imgh/2), imgw,imgh);
}
}
boolDoRefresh = false;
}
}
function mousePressed() {
boolDoRefresh = true;
}