String title"bombs and birds."; void setup() { size( 640, 480 ); horizon= height/3; reset(); } void reset() { //// Bird starts at random height, on the left side. birdX= 0; birdY= random(20,horizon); birdDX= random(1,10); birdDY=0; birdR= random(100,255); birdG= random(200); birdB= random(200); birdW= 60 * random(0.5,3.0); birdH= birdW/5; //// How many birds? numbirds= int( random(1,10) ); } /** Next frame */ void draw() { background( 200, 220, 255 ); fill(0); text( "q to quit; r to reset; b drops bomb", 20, 30 ); //++ scene(); action(); show(); tell(); } void tell() { //// Titles, score, etc. text( title, width/3, 20 ); } void show() { //// show all objects: monster, bird, bomb // Bird,flapping wing. fill( birdR, birdG, birdB ); flockDraw( numbirds, birdX,birdY, birdW, birdH ); // Bomb if (bombY>0) { fill( birdR*2/3, birdG*2/3, birdB*2/3 ); ellipse( bombX, bombY, birdW/10,birdH ); } } void flockDraw( int n, float x, float y, float w, float h ) { //// Draw flock of n birds float down=0; for (int j=0; j width+200) reset(); if (bombY>0) { bombX += bombDX; bombY += bombDY; bombDY += gravity / frameRate ; if (bombY>height) bombY=0; // Bomb disappears (Y=0) } //// Monster Mash //-- omitted. } void keyPressed() { if (key == 'q') exit(); if (key == 'r') reset(); if (key == 'b') bombDrop(); } void bombDrop() { bombX= birdX - birdW/2; bombY= birdY; bombDX= birdDX * 3/4; bombDY=0; }