Modify a text file: $/waves.java
$/waves.java
float surface=100; float sunX=500, sunY=50; float octoX=100, octoY=200; float fishX=50, fishY=300; float sharkX=500, sharkY=400; void setup() { size(800,600); } void draw() //// Next frame. { scene(); fish(); //// school of fish swim to the right. shark(); //// Shark chases fish. octopus(); //// Octopus -- 8 arms point toward shark. } void scene() //// waves on surface, rocks at bottom. { background( 200,200,255 ); // (Sky) text("sun",sunX,sunY); //// Water fill( 0, 150, 0 ); //// Waves noStroke(); rectMode(CORNER); rect(0,surface, width,height); for (float x=0; x
width/2; x -= 2*rockW + 40 ) { ellipse( x, y, rockW, 0.75*rockW ); rockW /= 2; } } void fish() //// school of fish swim to the right. { text("Fish1: BIG LEADER",fishX,fishY); text("Fish2: Smaller",fishX+30,fishY+20); text("Fish3: even smaller",fishX+60,fishY+40); text("Fish4: tiny",fishX+90,fishY+60); text("... up to 8 fish",fishX+120,fishY+80); } void shark() //// Shark chases fish. { text("Shark!!!!!",sharkX,sharkY); } void octopus() //// Octopus -- 8 arms point toward shark. { octoX= mouseX; octoY= mouseY; fill(127,0,127); rect(octoX,octoY,80,120); ellipse(octoX,octoY-60,80,80); fill(200,200,0); triangle(octoX-20,octoY-20, octoX+20,octoY-20, octoX,octoY); //// Eye fill(255,255,200); stroke(0); ellipse(pmouseX,pmouseY-70,30,30); noStroke(); fill(0,0,255); ellipse(mouseX,mouseY-70,10,10); //// Legs fill(127,0,127); text( "8 legs go here",octoX-40, octoY+75); }