//Philip Paniccia //Midterm String title= "Midterm CST 112 Wed Evening"; String author= "Philip Paniccia"; boolean day; float x,y,w,h; float sunX,sunY; float birdX, birdY; float witchX, witchY; float octoX, octoY; float horizon; void setup(){ size (600,500); x= width/2; y= height/2; w= 60; h= 20; witchX= width-50; birdY= horizon -50; octoX= width/2; octoY= horizon+200; sunX= 400; sunY= 50; horizon= 150; day= true; //reset(); } void draw(){ //draw the frames scene(); buttons(); if(day){ bird(); }else{ witch(); octopus(); } } void scene(){ //drawing sky and water //Sky if (day){ background(50,200,255); fill(255,255,0); noStroke(); ellipse(sunX, sunY, 50, 50); }else{ background(100,100,200); fill(240,180,220); noStroke(); ellipse(sunX-150,sunY, 50, 50); } text( sunY, 10,20 ); //Water fill(100,200,100); noStroke(); rect(0,horizon, width, height-horizon); } void bird(){ //draw bird and make bird move' //float birdX= width/2; float birdY= horizon-50; fill(145,40,130); triangle(birdX,birdY, birdX-w,birdY-h, birdX-w,birdY+h); triangle(birdX-25,birdY, birdX-w,birdY-h-25, birdX-w,birdY+h+25); //move bird birdX= (birdX+3); //if(birdX>width*2){ //birdX=0; //} if(birdX>width+100){ day= false; reset(); } } void witch(){ //draw witch //float witchX= width-50; float witchY= horizon-100; //body fill(150,100,50); rect(witchX,witchY, 25,50); //head fill(255,0,0); ellipse(witchX+13,witchY-10, 25,25); //legs fill(0,255,0); rect(witchX,witchY+50, 10,25); rect(witchX+15,witchY+50, 10,25); //hat strokeWeight(3); stroke(0); line(witchX-10,witchY-15, witchX+30,witchY-15); fill(0); triangle(witchX,witchY-15, witchX+25,witchY-15, witchX+15,witchY-35 ); //broom drawBroom( witchX-25, witchX+50, witchY+50 ); //make witch move witchX= (witchX-2); if (witchX < -75){ day= true; reset(); } } void drawBroom( float x1, float x2, float y ) { //// Broom from x1 to x2, at y strokeWeight(6); stroke(200,150,100); line( x1, y, x2, y ); //// Bristles at x2. strokeWeight(1); float yy= y-10; for (int j=0; j<7; j++ ) { line( x2,yy, x2+40,yy ); yy += 3; } noStroke(); // Reset } void octopus(){ float octoDY= 1; //// Octopus: up & down octoY += octoDY; if (octoY < horizon) { octoDY = +1; // Sink slowly. } else if (octoY > height-50) { octoDY = -3; } //// Draw body & slanty legs; fill( 255,0,255 ); rect( octoX-20,octoY-25, 40, 50 ); ellipse( octoX,octoY-30, 40, 40 ); // Legs stroke( 255,0,255 ); strokeWeight(2); float slant=0; if (octoDY<0) { // Going up. slant = (frameCount % 10 < 5) ? -3 : +3; } for( float x=octoX-20+2; x