//project 2 //Adam Kochen void setup () { size(800,600); } 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; float bird1X, bird1Y=10; float bird2X, bird2Y=40; float bird3X, bird3Y=60; float birdXA =100 , birdYA=100; void draw(){ //Next Frame scene(); treasure(); sun(); demonLord(); hero(); score(); 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); text(score,20,700); } 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); } void eat(){ // score= score-20; background(255,0,0); heroX=random(0,750); heroY=random(250,550); } void mousePressed(){ // demonLordX= mouseX; demonLordY= mouseY;} void head(float x , float y , float w, float h) { //make head ellipse( x, y, w, h); } void body(float x, float y, float w, float h) { //make body rect(x ,y ,w ,h); } void birdBody(float x, float y) { noStroke(); triangle(x,y,x-30,y-10,x-30,y+10);} void keyPressed(){ if (key == 'q') {exit();} ; }