xxxxxxxxxx
210
let al;
let at, ab;
let riv, fic, pol, net;
let bitesize = 5
let biteoff=0
let bitespeed=0.3
let crossed;
let over;
let eaten;
let midface;
let fullzawidth;
let al_y = 200
let zaShown;
let zas = [];
let alscale = 0.5
let za;
let zascale = 0.1
let zaspeed = 4
let za_x = 0
let za_score = 0
let noisehold = 0
let yumframes = 0
let yuckframes = 0
let yum2 = 0
let yuck2 = 0
let layer = [0,0,0,0]
function preload() {
al = loadImage('Al.png')
at = loadImage('Al_T.png')
ab = loadImage('Al_B.png')
za = loadImage('za.png')
riv = loadImage('river.jpg')
fic = loadImage('ficus.jpg')
pol = loadImage('polarbear.png')
net = loadImage('internet.png')
}
function setup() {
createCanvas(600, 600);
fullzawidth = za.width*zascale
for (let i=0;i<1;i++) {
zas.push(new Pizza(-za.width*zascale, al_y, width/2+30))
}
}
function taste() {
za_score = random()
noisehold = random()
if (za_score>0.5) {
yumframes = 100
yuckframes = 0
} else {
yuckframes = 100
yumframes = 0
}
//console.log(int(2*(za_score>0.5)) + int(noisehold>0.5))
layer[int(2*(za_score>0.5)) + int(noisehold>0.5)] = 255
}
function draw() {
background(220);
push()
strokeWeight(5)
line(width/2+10,al_y+50,width/2+100,al_y+102)
line(width/2-10,al_y+50,width/2-100,al_y+102)
line(width/2+100,al_y+102,width/2+60,al_y+210)
line(width/2+100,al_y+102,width/2+180,al_y+210)
line(width/2-100,al_y+102,width/2-60,al_y+210)
line(width/2-100,al_y+102,width/2-180,al_y+210)
translate(50, al_y+45)
noFill()
strokeWeight(10)
rect(0,4,500, height-100-al_y)
pop()
for (let i=0;i<zas.length;i++) {
z = zas[i]
if (z.eaten) {
taste()
zas.push(new Pizza(z.startpos.x, z.startpos.y, z.end))
zas.splice(i, 1)
}
}
for (let i=0;i<layer.length;i++) {
layer[i] *= 0.99
}
push() //bottom
translate(width/2, al_y)
biteoff = (sin(frameCount*PI*bitespeed/10)/2+1)*bitesize
imageMode(CENTER)
image(ab,biteoff/4*sin(frameCount*PI*bitespeed/80),biteoff, ab.width*alscale, ab.height*alscale)
pop()
for (let i=0;i<zas.length;i++) {
z = zas[i]
z.progress(zaspeed)
z.show()
}
push() //top
translate(width/2, al_y+10)
rotate(biteoff/180*sin(frameCount*PI*bitespeed/200))
imageMode(CENTER)
image(at,0,-at.height*alscale, at.width*alscale, at.height*alscale)
pop()
push()
translate(width/2, al_y+100)
strokeWeight(1)
fill(220, 255, 220)
if (yumframes > 0) {
fill(220-yumframes, 255, 220-yumframes)
yumframes -= 1
}
ellipse(100, 0, 120, 50)
fill(0)
textAlign(CENTER)
textFont("Courier New")
textSize(20)
text("yum", 100, 2)
fill(255, 220, 220)
if (yuckframes > 0) {
fill(255, 220-yuckframes, 220-yuckframes)
yuckframes -= 1
}
ellipse(-100, 0, 120, 50)
fill(0)
text("yuck", -100, 2)
fill(255, 220, 180)
rectMode(CENTER)
rect(-180, 120, 110, 50)
fill(0)
textSize(10)
text("Throw AAA\nbatteries\ninto a river", -180, 110)
fill(220, 220, 255)
rect(-65, 120, 110, 50)
fill(0)
textSize(10)
text("Water a ficus", -65, 120)
fill(255, 220, 180)
rect(65, 120, 110, 50)
fill(0)
textSize(10)
text("Gaze at a picture\nof a polar bear", 65, 115)
fill(220, 220, 255)
rect(180, 120, 110, 50)
fill(0)
textSize(10)
text("Invent the\ninternet", 180, 115)
pop()
push()
rect(width-200, al_y-46, 150, 90)
textAlign(CENTER)
text("Al's Pizza Review", width-125, al_y-30)
textSize(30)
text("/5", width-110, al_y+20)
translate(width-150, al_y+10)
if (za_score) {
rotate(sin(99*(za_score+noisehold))/5)
text(round(za_score*5, 1), za_score*noisehold, noisehold+za_score-1)
}
pop()
push()
imageMode(CENTER)
rectMode(CENTER)
translate(120, height*0.8)
strokeWeight(layer[0]/25.5)
stroke(layer[0],layer[0]*0.9,0)
rect(0,0,90,60)
image(riv, 0, 0, 90, 60)
strokeWeight(layer[1]/25.5)
stroke(0, 0, layer[1])
rect(115, 0, 90, 60)
image(fic, 115, 0, 90, 60)
translate(width/2-55, 0)
strokeWeight(layer[2]/20)
stroke(layer[2],layer[2]*0.9,0)
rect(0,0,90,60)
image(pol, 0, 0, 90, 60)
strokeWeight(layer[3]/25.5)
stroke(0, 0, layer[3])
rect(115, 0, 90, 60)
image(net, 115, 0, 90, 60)
pop()
}