// Project 1 // Justin Gonzalez 9/12/14 int score=0 ; float horizon=600; float sunx=100 , suny=100; float jeffx=300 ,jeffy=300; float xerathx=400, xerathy=400; float cassx=200, cassy=200; float bobx=500, boby=500; float goldx=500, goldy=300; int n=3; //# of pairs void setup(){ //setup// size(1300,900); horizon= height/4; suny= horizon/2; jeffx=width/2; jeffy= height/2; xerathx=30; } void draw(){ //next frame// scene(); hero(); monster(); scoring(); gold(); flock(n,x,y,w,h); x+=10; if (x>width+200){ y=random(100,500); x=0; } } void scene(){ //sky, sun ,etc background(100,180,255); fill(255,255,0); ellipse(sunx,suny,50,50); //sun sunx= sunx+2; //grass fill(0,255,0); rectMode(CORNER); rect(0,horizon,width,height*3/4); //grass fill(0); text("Score:" + score,1100,100); } void bird(float x, float y, float w, float h){ // bird fill(255,100,210); stroke(0); triangle( x,y, x-w,y-h/3,x-w,y+h/3); x=x+2; //move bird x=x+2; if (x>width+200){ y=random(100,500); x=0; n= int (random (3,10) ); } } void flock(int n, float x,float y, float w, float h){ float xx=x; float ww=w; float hh=h*1.25; //Lead Bird bird(xx,y,w,h); xx=xx - 1.25 *w ; //Pairs of Followers for (int j=1; j width) {sunscore();} if(dist (xerathx,xerathy,jeffx,jeffy) <50) {eat();} } void mousePressed(){ //click goldx= mouseX; goldy=mouseY; } void eat(){ /*when the monster eats the hero subtract points amd characters return to their corners*/ score = score-50; jeffx=1300; xerathx=0; background(255,0,0); } void sunscore(){ // as the sun passes the width add points score=score+10; sunx=0; } void gold(){ //draw and place gold fill(255,205,0); ellipse(goldx,goldy,25,25); //gold scoring if(dist (goldx,goldy,jeffx,jeffy) <50) {goldscore();} } void goldscore(){ score=score+100; goldx=random(50,1250); goldy=random(horizon,850); jeffx=1300; xerathx=0; background(255,230,0); } void keyPressed(){ if (key=='q') exit(); //--if (key=='r') ; }