//project 2 //Adam Kochen int score=0; float horizon=150; float sunX=50,sunY=30; float demonLordX=random(500,800), demonLordY= 500; float heroX=random(0,300) ,heroY=random(300,500); float dayScore = 2; float treasureX= random(20,780), treasureY = random(200,600); float travelX = 0 , travelY = 0; float bodyW = 40 , bodyH =80; /* 0-0 loat bird1X, bird1Y=10; float bird2X, bird2Y=40; float bird3X, bird3Y=60; float birdXA =100 , birdYA=100; 0-0 */ int n; //# of bird pairs float x, y; //position float w , h; //bird size String myName = "Adam Kochen"; String gName = "Project2 with flock of birds"; void setup () { size(800,600); reset(); } void draw(){ //Next Frame scene(); treasure(); sun(); demonLord(); hero(); score(); flock(); // bird(); } void scene(){ //sky noStroke(); if(dayScore%2==0) {background(0,200,255); } else{ background(0,0,123); }; fill(0,255,0); rect(0,horizon,800,500); fill(0); text(myName + " - " + gName,300,10); } void flock(){ //0-0 x = 600; //0-0 y = 300; //0-0 if(x-60*n < width){ x += random(20); //0-0 } y = y-random(1,5)+random(1,5); w= 30; h= 20; fill(0); if(y > 80){ y=80; } if(y < 30){ y=30; } flock(n,x,y,w,h); if(x-60*n > width){ reset(); } //test text fill(0); //text("n "+n,10,10); //text("x "+x,10,20); text("y "+y,10,30); //text("w "+w,10,40); //text("h "+h,10,50); } void treasure(){ //draw treasure fill(255,0,0,0); rect(treasureX,treasureY,10,10); //treasure found if(dist(demonLordX,demonLordY,treasureX,treasureY)<60){ treasureX= random(20,780); treasureY = random(200,580); score= score + 20; background(255); } //draw coorinates travelX= dist(demonLordX,demonLordY,treasureX,treasureY); fill(100); text(travelX,20,20); } void sun(){ //draw sun ellipseMode(CORNER); if(dayScore%2==0) {fill(255,210,0); }else{fill(220); }; noStroke(); ellipse(sunX,sunY,40,40); sunX= sunX +2; //reset sun if(sunX > width+10){ sunX=50; dayScore=dayScore + 1; } } void demonLord(){ //make demonLord fill(0); body(demonLordX,demonLordY,bodyW,bodyH); ellipseMode(CORNER); head(demonLordX,demonLordY-40,40,40); strokeWeight(10); stroke(183,0,0); //horns if(mouseX horizon || mouseY > horizon) {demonLordY= demonLordY+ (mouseY - demonLordY)/5;} demonLordX= demonLordX+ (mouseX - demonLordX)/5; //Name demonLord fill(255,0,255); text("Demon",demonLordX,demonLordY+40); text("Lord",demonLordX+8,demonLordY+53); } void hero(){ //chase demonLord heroX= heroX+ (demonLordX-heroX)/90; heroY= heroY+ (demonLordY-heroY)/90; //make hero sword strokeWeight(10); stroke(183,178,180); if(demonLordX>heroX) { line(heroX+10,heroY+15,heroX+90,heroY+15);//blade noStroke(); fill(0,100,200); rect(heroX,heroY+10,50,10); //handle rect(heroX+49,heroY,8,30); //hand guard } else { line(heroX,heroY+15,heroX-50,heroY+15); //blade noStroke(); fill(0,100,200); rect(heroX-10,heroY+10,50,10); //handle rect(heroX-17,heroY,8,30); //hand guard } //make hero rectMode(CORNER); fill(255); body(heroX,heroY,bodyW,bodyH); //body head(heroX,heroY-40,40,40); //--ellipse(heroX,heroY-40,40,40); //head fill(200,50,200); //moving eye if(demonLordXwidth+500) { bird1X= 80; bird1Y= random(20,horizon); } if (bird2X>width+500) { bird2X= 80; bird2Y= random(20,horizon); } if (bird3X>width+500) { bird3X= 80; bird3Y= random(20,horizon); } // draw birds fill(255); // bird 1: red birdBody( bird1X, bird1Y); fill(100,100,100); birdBody( bird2X, bird2Y); fill(0); birdBody( bird3X, bird3Y); } 0-0 */