//Project #0// Static scene, dog, guy, birds// //Diana Alberto CST-112// //DECLARING GLOBAL DATA// float horizon; float guyX= width/2, guyY= height/2; //initial position of guy float guyDX= 5, guyDY= 2; float dogX= width/3, dogY= height/3;// initial position of dog int birdX=10, birdY=10; //initial position of bird int birdDX=1; int sunX= 750, sunY= 50; //position of sun float bombX=10, bombY=10, bombDY=0; //no bomb until y > 0 float gravity= 1.0; boolean eastbound= true; int speed; PFont f; // declaring a font variable void setup() { size(800, 600); // setting window size f = loadFont("FranklinGothic-Book-48.vlw"); //load font } void draw(){ //Move and show everything scene(); bird(); bomb(); guy(); dog(); //adding text to lower left hand corner textFont(f, 20); //specifying font fill(255); //specifying a white text color text("Diana Alberto-CST-112-Project #0", 15, 590); //display text } void scene () { //Sky, Sun, Grass fill(2,170,229); //blue sky noStroke(); rect(0,0, 800, 300); fill(8,196,40); //green grass noStroke(); rect(0, 300, 800, 300); fill(233, 255, 5); //display sun noStroke(); smooth(); ellipse(sunX, sunY, 70, 70); } void bird() { birdX= birdX + birdDX; //move the bird birdX= birdX % width; birdY= birdY + 3 - (int) random (5); fill(0); //display the black bird arc(birdX+40, birdY+45, 50, 50, 0, PI); arc(birdX+60, birdY+45, 40, 40, PI, 11*PI/6); if (birdY > 150) { birdY = birdY - 5; } else if (birdY < -200){ birdY= birdY - 10; } } void bomb() { // Make bomb fall from bird if (bombX>0) { bombX = birdX-10; bombDY= bombDY + gravity; bombY+= bombDY; } //Draw the bomb fill (255, 15, 216); ellipseMode(CENTER); ellipse( bombX, bombY, 20, 25); } void mousePressed() { // Drop bomb, when mouse is pressed. bombX= birdX; bombY= birdY; bombDY= 0; } void guy(){ fill(242, 15, 41); //guy's body rect(mouseX,mouseY, 40, 80); //guy's body follows mouse fill(240, 221, 203); //guy's head smooth(); ellipse(mouseX+20, mouseY-20, 40, 40); stroke(0); //guy's legs strokeWeight(9); line(mouseX-1, mouseY+120, mouseX+1, mouseY+80); line(mouseX+39, mouseY+80, mouseX+40, mouseY+120); } void dog(){ fill(142, 66, 16); //dog's head noStroke(); ellipse(pmouseX-100, pmouseY+80, 40, 40); fill(142, 66, 16); //dog's body noStroke(); ellipse(pmouseX-150, pmouseY+100, 80, 40); stroke(142, 66, 16); //dog's legs strokeWeight(8); line(mouseX-120,mouseY+100, pmouseX-120, pmouseY+130); line(mouseX-140,mouseY+100, pmouseX-140, pmouseY+130); line(mouseX-160,mouseY+100, pmouseX-160, pmouseY+130); line(mouseX-180,mouseY+100, pmouseX-180, pmouseY+130); }