//Hugo's project #1+2 //Global Declaration int birdX=100, birdY=100; ///position/starting point of the bird int birdDX=10; //speed of bird at which is traveling int guyX=100,guyY=300, guyDX=10, guyDY=5; float horizon; int dogX=100,dogY=200; float bombX=0, bombY=0, bombDY=0; float gravity= 0.5 * 9.81 / frameRate; ///speed boolean eastbound=true; int speed; //float cloudX,cloudY,cloudW,cloudH; //int cloudsN = 5; void setup () { size (800,600); ///size of window horizon=250; //cloudX = 100; //cloudDx = 20; //cloudY = 150; //cloudDY = 0; //cloudW = 100; //cloudH = 50; } void draw () /// list of items to be included { scene(); creature( ); dog(); bird(); bomb(); //grass(); // moveclouds(); //cloud(); } void scene ()/////what it should look like { background (11,56,153); fill(6,193,79); rect(0,horizon,800,800); fill(31,85,37); rect(0,240,800,10); // fill (14,108,52); //rect (0,242,800,5); fill (247,248,252); ellipse(600,50,90,90); } void creature ()//appearance of guy + creature boucing { guyDX= guyX>20 && guyX < width -20 ? guyDX : -guyDX; /// creature bouncing guyDY= guyY>horizon && guyYdogX ){ ellipse( dogX+30, dogY-10, 20, 10 ); /// dog turns right as soon as it hits the line limit } else { ellipse( dogX-30, dogY-10, 20, 10 ); /// dog turns left as soon as it hits the line limit } } void bird()///bird flies accross the sky { birdX = birdX + birdDX; birdX = birdX % width/1; fill( 23, 76, 121 ); triangle( birdX+20,birdY+25, birdX-15,birdY-15, birdX-30,birdY+45 ); if (birdY >150){ birdY = birdY - 10; } else if (birdY <-100){ birdY= birdY - 10; } } void bomb() { ////draw bomb if (bombX > 0) { bombX= birdX - 5; bombDY= bombDY + gravity; bombY += bombDY; if (bombY > height) { bombY=0; background(255); } fill( 0, 255, 100 ); ellipseMode( CENTER ); triangle( bombX-12,bombY-15, bombX+12,bombY-15, bombX,bombY+15 ); if ( abs(guyX-bombX)<30 && abs(guyY-bombY)<30 ) { } } } void mousePressed() { /// when mouse is click bomb will drop bombX = birdX; bombY = birdY; bombDY= 0; } void keyPressed() { if (key == 'd') { speed -= 5; if (speed<1) speed= 20; frameRate( speed ); } } //void moveclouds(){ //cloudX = cloudDX; //if (cloudx > width) { // cloudx = 100; ///cloudsN = 0.5 int(random (1,10) ); //cloudW = 50 + random (100); // } //} //void clouds () //{ // float x,y,w,h; ///w = cloudW; ///h = cloudH; /// x = cloudX; /// y = cloudY; /// ellipseMode (CORNER); ///fill(200,225,250,150); ///ellipse (x,y,w,h); //for (i = 0; i < 5; i++) // x = x - 80; // y = y - 5; //w = w * 0.9; //h = h *0.9; //} //if( mouseX > X1 && mouseX < X2) //if (mouseY > Y1 && mouseY < X2) //color c = color(225,127,50); //if you want to set a color //example int r,g,b; /// drawing arms on the zoog ////int foo (float x, int of) { //}