Modify a text file: $/39/p1a.java
$/39/p1a.java
//// project1a.java (BAM:3913a) Practice project #1a. //// See: http://www.suffolk.li/cst112/39cst112/students/project1.html void setup() { //// Screen size, etc. size( 623, 479 ); } void draw() { //// Next frame. scene(); hero(); } void scene() { //// Sky, sun, house, tree. background( 200, 220, 255 ); rectMode( CORNERS ); fill( 0, 200, 50 ); rect( 0, height/3, width, height ); fill(0,0,255); sun(); // Title, author text( "Practice problem #1a", 200, 20 ); text( "Bruce Alan Martin ('13/8/13)", 20, height-20 ); } void sun() { //// Sun moves across sky. fill( 255,255,0 ); noStroke(); ellipse( frameCount % width , height/6, 20, 20 ); stroke(0); // Restore stroke } void hero() { //// Follows mouse // noCursor(); body(); head(); ellipse( mouseX-10, mouseY-40-20, 10, 2 ); ellipse( mouseX+10, mouseY-40-20, 10, 2 ); fill( 0, 0, 255 ); text( "Zoog", mouseX-10, mouseY-10 ); } void body() { //// Draw the body. fill( 0,255,255 ); rectMode( CENTER ); rect( mouseX, mouseY, 50, 80 ); } void head() { //// Draw the head fill( 255,200,200 ); // Head ellipse( mouseX, mouseY-40-15, 40, 40 ); } void eyes() { //// Eyes fill(255); ellipse( mouseX-10, mouseY-40-20, 12, 12 ); ellipse( mouseX+10, mouseY-40-20, 12, 12 ); fill( 0, 0, 255 ); ellipse( mouseX-9-random(2), mouseY-40-20, 4, 4 ); ellipse( mouseX+9+random(2), mouseY-40-20, 4, 4 ); } void keyPressed() { //// When key is pressed, draw the eyes. eyes(); if (key == 'e') { eyes(); } if (key == 'E') { eyes(); } if (key == 'q') { exit(); } }