/***************** Qianlin Xu 2018/09/29 Skeet Shooting *************/ //declaring varibales //float float cloud1X; float cloud1PosY; float cloud1Speed; float cloud2X; float cloud2PosY; float cloud2Speed; float frisbee1X; float frisbee1PosY; float frisbee1Speed; float frisbee1Angle; float frisbee2X; float frisbee2PosY; float frisbee2Speed; float frisbee2Angle; int score=0; //set up void setup(){ size(400,400); ellipseMode(CENTER); rectMode(CENTER); noCursor(); //initialize varibales cloud1X=340; cloud1PosY=random(40,160); cloud1Speed=random(0.1,0.5); cloud2X=100; cloud2PosY=random(80,180); cloud2Speed=random(0.1,0.5); frisbee1X=-50; frisbee1PosY=random(140,400); frisbee1Speed=random(3,6); frisbee1Angle=random(sin(frameCount*0.01),sin(frameCount*0.05)); frisbee2X=450; frisbee2PosY=random(140,400); frisbee2Speed=random(3,6); frisbee2Angle=random(sin(frameCount*0.01),sin(frameCount*0.05)); } //functions void draw(){ //sets background colour to light blue background(255,255,193); //score counter text fill(0); text("Score:"+score,10,20); //function calls drawBackground(); drawCloud1(); drawCloud2(); drawFrisbee1(); drawFrisbee2(); //drawFrisbee3(); //drawFrisbee4(); drawAimPoint(); } //draw Background void drawBackground(){ //draw sky layer noStroke(); fill(255,210,165); rect(200,160,400,100); fill(211,140,173); rect(200,250,400,80); fill(138,121,175); rect(200,320,400,60); //draw mountain fill(14,173,59); ellipse(120,420,280,520); ellipse(380,400,280,400); //draw sun fill(215,70,13); ellipse(320,40,40,40); } //draw cloud1 void drawCloud1(){ fill(255,255,255,200); ellipse(cloud1X,cloud1PosY,240,60); //make cloud move if(cloud1X>-120){ cloud1X=cloud1X-cloud1Speed; } else{ //reset cloud1X=500; cloud1PosY=random(40,140); cloud1Speed=random(0.1,0.5); } } //draw cloud2 void drawCloud2(){ fill(255,255,255,230); ellipse(cloud2X,cloud2PosY,120,40); //make cloud move if(cloud2X>-120){ cloud2X=cloud2X-cloud2Speed; } else{ //reset cloud2X=500; cloud2PosY=random(40,140); cloud2Speed=random(0.1,0.5); } } //draw aim point void drawAimPoint(){ noFill(); stroke(0); ellipse(mouseX,mouseY,20,20); line(mouseX-13,mouseY,mouseX-7,mouseY); line(mouseX+13,mouseY,mouseX+7,mouseY); line(mouseX,mouseY-13,mouseX,mouseY-7); line(mouseX,mouseY+13,mouseX,mouseY+7); fill(0); ellipse(mouseX,mouseY,4,4); } //draw frisbee1 void drawFrisbee1(){ fill(0); ellipse(frisbee1X,frisbee1PosY,40,20); //make the frisbee fly through sky if(frisbee1X<450){ frisbee1X=frisbee1X+frisbee1Speed; frisbee1PosY=frisbee1PosY-frisbee1Angle; } else{ //reset frisbee1X=random(-50,-200); frisbee1PosY=random(140,400); frisbee1Speed=random(3,6); frisbee2Angle=random(sin(frameCount*0.01),sin(frameCount*0.05)); } //If frisbee is clicked,disappear if (mousePressed){ if(mouseX>frisbee1X-20){ if(mouseX<frisbee1X+20){ if (mouseY>frisbee1PosY-10){ if (mouseY<frisbee1PosY+10){ //then reset score=score+1; frisbee1X=random(-50,-200); frisbee1PosY=random(140,400); frisbee1Speed=random(3,6); frisbee1Angle=random(sin(frameCount*0.01),sin(frameCount*0.05)); } } } } } } //draw frisbee2 void drawFrisbee2(){ fill(0); ellipse(frisbee2X,frisbee2PosY,40,20); //make the frisbee fly through sky if(frisbee2X>-50){ frisbee2X=frisbee2X-frisbee2Speed; frisbee2PosY=frisbee2PosY-frisbee2Angle; } else{ //reset frisbee2X=random(450,600); frisbee2PosY=random(140,400); frisbee2Speed=random(3,6); frisbee2Angle=random(sin(frameCount*0.01),sin(frameCount*0.05)); } //If frisbee is clicked,disappear if (mousePressed){ if(mouseX>frisbee2X-20){ if(mouseX<frisbee2X+20){ if (mouseY>frisbee2PosY-10){ if (mouseY<frisbee2PosY+10){ //then reset score=score+1; frisbee2X=random(450,600); frisbee2PosY=random(140,400); frisbee2Speed=random(3,6); frisbee2Angle=random(sin(frameCount*0.01),sin(frameCount*0.05)); } } } } } }