// ZOOG with VARIABLES //all variables float monsterX=300, monsterY=300; // Bird: float birdX, birdY, birdDX=10, birdDY=0; float birdW=60, birdH=10; float birdR=255, birdG=0, birdB=0; float bird2= random(1,300); // Bomb : float bombX,bombY, bombDX, bombDY; float gravity= 9.81; //horizon float horizon, sunX, sunY; //house float houseX, houseY; //zoog float zoogX, zoogY; float eyeR,eyeG,eyeB; //ship float shipX, shipY; //start of sketch void setup() { size(600,600); smooth(); fill(0); horizon = height/3; sunY = horizon/2; sunX = width/4; houseX=width*2/3; houseY=horizon-50; frameRate(15); reset(); } void reset() { //bird start point birdX= 0; birdY= random(20,horizon); birdDX= random(5,15bb); birdDY= 0; birdR= random(100,255); birdG= random(200); birdB= random(200); birdW= 60 * random(0.5,3.0); birdH= birdW/5; } void draw() { scene(); zoog(); // ship(); txt(); action(); show(); } void show() { //// show all objects: bird, bomb // Bird,flapping wing. fill( birdR, birdG, birdB ); triangle( birdX,birdY, birdX-birdW,birdY-birdH, birdX-birdW,birdY+birdH ); // Wing float flap= 2*birdH; if ( frameCount/9 % 2 == 0) flap= -flap; triangle( birdX-birdW/3,birdY, birdX-birdW,birdY, birdX-birdW*2/3,birdY+flap ); // Bomb if (bombY>0) { fill( birdR, birdG, birdB ); ellipse( bombX, bombY, birdW/10,birdH ); } } void action() { //// Bird flies, bomb drops (if visible) birdX += birdDX; if (birdX > width+200) reset(); if (bombY>0) { bombX += bombDX; bombY += bombDY; bombDY += gravity / frameRate ; if (bombY>height) bombY=0; // Bomb disappears (Y=0) } } void bombDrop() { bombX= birdX - birdW; bombY= birdY; bombDX= birdDX * 3/4; bombDY=0; } void txt() { fill(0); text("Created By Enrico Fucci", 10,590); text("ZOOOOOG",300,20); text( "q to quit; r to reset; b drops bomb", 20, 30 ); } void scene() { //sky, sun, grass text("Created By Enrico Fucci", 500,100); background(58,153,203); //blue sky sun(); house(); //title stroke(1); fill(0); fill(15,165,26); //grass rect(0, horizon, width, height+3/4);//horizon } //sun void sun() { //sun move to right sunX= sunX+.5; sunX= sunX % width; sunY= horizon -100*sin( PI * sunX/width); //sun rise and set stroke(1); fill(#F0DA11); ellipse(sunX,sunY,60,60); } void house() { fill(#5A5A59); //noStroke(); //house rectMode(CORNER); rect(houseX,houseY,120,80); //roof triangle(houseX, houseY, houseX+120, houseY, houseX+60, houseY-45); //window and door fill(255); rect( houseX+5,horizon-50, 20, 30 );//window left line(houseX+25,horizon-35,houseX+5,horizon-35); rect( houseX+95,horizon-50, 20, 30 );//window right line(houseX+115, horizon-35,houseX+95,horizon-35); rect( houseX+50,horizon-50, 20, 50 );//door } void zoog() { zoogX= zoogX + (pmouseX-zoogX); zoogY= pmouseY + (pmouseX-zoogX); fill(150); rectMode(CENTER); rect( zoogX,zoogY, 20, 100 ); float shoulder= zoogY; float headY= shoulder-30; float hip= zoogY+40; float tilt=(mouseX-pmouseX); //float tilt=(mouseX-pmouseX); // Head & eyes fill(0,150,35); ellipse( zoogX,headY, 60,60 ); fill(0); ellipse( zoogX-19,headY, 16,32 );//left eye ellipse( zoogX+19,headY, 16,32 );//right eye eyeR=random(255); eyeB=random(255); eyeG=random(255); fill(eyeR,eyeG,eyeB); ellipse( zoogX-19, headY, 6,10 );//eyeball left ellipse( zoogX+19, headY, 6,10 );// eyeball right //mouth fill(255,0,0); ellipse(zoogX,headY+15,17,7); fill( 255, 0, 0 ); // Legs: left (-10) & right (+10) tilt toward mosue movement line( zoogX-10,hip, zoogX-10+tilt,hip+40 );//left leg line( zoogX+10,hip, zoogX+10+tilt,hip+40 );//right leg //arms line(zoogX+10,zoogY+10,zoogX+25,zoogY+30); line(zoogX-10,zoogY+10,zoogX-25,zoogY+30); } void ship() { shipX= shipX + (zoogX-shipX) / 30; shipY= shipY + (zoogY-shipY) / 30; shipY= shipY