// Project 2 // Hugo Bonilla //project 1 + flock of birds int score=0; float sunX=100, sunY=100; float horizon; float tomX=300, tomY=300; float jerryX=400, jerryY=400; float goldX=400; float goldY=300; int n; float x = 100; float y = random(0,height/4); float w = 10; float h = 10; float pairs= random(3,7); float shrink= .08 ; void setup() { //Setup size(800,600); horizon= height/4; sunY= horizon/2; tomX= width/2; tomY= height/2; } void draw() { //Next Frame scene(); hero(); monster(); score(); gold(); eat(); //flock of birds setup flock( n , x ,y ,w ,h); x+= random (20); if (x>width*1.5) x=0; y = y-5 + random(10); // title and author textSize(17); fill(0); text( "project 2" , width/2.5, 30 ); textSize(15); text("Hugo Bonilla", 20, height-20); } void scene() { background(136,184,247); //yellow sun fill(255,255,0); ellipse( sunX,sunY, 50,50); //horizon fill(33,229,66); rectMode(CORNER); rect(0, horizon, width, height*3/4); // sun moves across he sky sunX=sunX + 2; if (sunX > width*1.25) { sunX=0; sunY= random ( 10, horizon-20); score += 50; } } void hero() { // move & draw tom //move tom tomX= tomX + ( mouseX-tomX)/15; tomY= tomY + ( mouseY-tomY)/20; if (tomY < horizon) { tomY = horizon; } //tom's body textSize(5); text("Tom" , tomX,tomY); fill(170,165,165); rectMode(CENTER); rect( tomX, tomY ,50 , 80,10); ellipseMode(CENTER); fill(255,220,234); ellipse(tomX,tomY, 40 , 65); fill(3,3,3); textSize(15); text("Tom" , tomX-16,tomY); // ears fill(165,165,165); triangle(tomX-14,tomY-60,tomX,tomY-60, (tomX-8), tomY-75); triangle(tomX+14,tomY-60,tomX,tomY-60, (tomX+8), tomY-75); //tom's head fill(165,165,165); ellipse(tomX, tomY -40, 40 , 50); // eyes fill(255,200,0); ellipse(tomX-8,tomY-50,10,15); ellipse(tomX+8,tomY-50,10,15); } void monster() { // move & draw jerry //move jerry jerryX = jerryX + ( goldX - jerryX)/75; jerryY += ( goldY - jerryY )/75; if (jerryY < horizon) { jerryY= horizon; } // draw jerry //jerry's body rectMode(CENTER); fill(209,141,57); rect(jerryX , jerryY, 50,80,10); ellipseMode(CENTER); fill(252,206,148); ellipse(jerryX, jerryY ,40,65); fill(0); textSize(15); text("Jerry" , jerryX-16,jerryY); // ears fill(209,141,57); ellipse(jerryX-14,jerryY-60, 20,25); ellipse(jerryX+14,jerryY-60, 20,25); //jerry's head fill(209,141,57); ellipse(jerryX,jerryY - 40,40,50); // eyes fill(252,250,247); ellipse(jerryX-8,jerryY-50,10,15); ellipse(jerryX+8,jerryY-50,10,15); } void score() { textSize(15); fill(1,3,3); text( "Score = " + score , 600, horizon/ 3); } void gold() { //draw gold + gold score fill(234,188,69); ellipse(goldX,goldY,15,15); if ( dist(tomX,tomY,goldX,goldY) < 50) { goldX=random(100,600); goldY=random(200,500); score += 100; } if ( dist(jerryX,jerryY,goldX,goldY) < 40) { goldX= random(100,600); goldY= random(200,500); score += -100; } } void bird( float x ,float y ,float w ,float h) { fill(0); triangle(x,y, x-w , y-h/3, x-w, y+h/3 ); } //* not sure how to make flock of birds stay above the horizon void flock( int n , float x, float y, float w , float h) { float xx= x; float up =0; float ww=w; float dy = h/3; float yy= y; dy= h/3; dy += h/3; //lead bird bird ( xx ,y ,w,h); // make flock of birds for (int j=0;j