Modify a text file: $/p1a.java
$/p1a.java
//// Project 1a //// B.A.Martin CST 112 String title= "Project 1a"; String author= "B.A.Martin -- CST 112"; int georgeX, georgeY; int look; int muttX, muttY, tickX, tickY; int sunX=0; int horizon; //// SETUP: screen size void setup() { size( 640, 480 ); horizon= height/4; } //// Next frame. void draw() { scene(); action(); show(); credits(); } //// Draw the scene. void scene() { background( 100, 200, 250 ); fill( 200, 250, 200 ); rectMode( CORNERS ); rect( 0,horizon, width, height ); // Sun. fill( 255,255,0 ); noStroke(); ellipse( (int) sunX, 40, 30,30 ); sunX= (sunX + 1) % width; stroke(0); // House rectMode( CORNER ); fill(255,0,0); rect( 120, horizon-50, 60, 50 ); triangle( 120,horizon-50, 180,horizon-50, 150,horizon-70 ); fill(0); rect( 125, horizon-35, 10, 10 ); rect( 165, horizon-35, 10, 10 ); rect( 142, horizon-35, 16, 33 ); // Trees. fill( 150, 0, 0 ); rectMode( CORNER ); rect( 200, horizon, 20, -60 ); rect( 300, horizon, 25, -70 ); rect( 400, horizon, 15, -50 ); noStroke(); fill( 0, 120, 0 ); ellipse( 210, horizon-70, 35, 35 ); fill( 50, 180, 50 ); ellipse( 312, horizon-85, 55, 40 ); fill( 50, 250, 100 ); ellipse( 407, horizon-45, 30, 30 ); stroke(0); } //// Move the actors. void action() { // Move George //-- georgeX= mouseX; //-- georgeY= mouseY; georgeX= georgeX + (mouseX-georgeX) / 10; // Chase the mouse. georgeY= georgeY + (mouseY-georgeY) / 20; if (georgeY < horizon) georgeY= horizon; // Look in direction of motion. look=0; if (mouseX>pmouseX) look = 2; if (mouseX
georgeX) muttFace= -40; rect( muttX + muttFace, muttY-20, 30, 20 ); // Bug fill( 150 ); float xx= random( 6 ); ellipse( tickX, tickY, 20, 10 ); line( tickX-10, tickY+4, tickX-12+xx, tickY+8 ); line( tickX-5, tickY+4, tickX-7+xx, tickY+8 ); line( tickX+5, tickY+4, tickX+3+xx, tickY+8 ); line( tickX+10, tickY+4, tickX+10+xx, tickY+8 ); } //// Put some text on the screen.. void credits() { fill( 0 ); text( title, width/3, 20 ); text( author, 20, height-20 ); }