Modify a text file: $/sal.java
$/sal.java
/// fishtank float left=50,top=50,right=550,bottom=350; float fishX=left, fishY=top+10; float fishDX=3, fishDY=2; Pisces moe, curly, larry; void setup() { size(600,500); moe= new Pisces(); moe.r=255; moe.x=100; moe.y=100; curly= new Pisces(); curly.g=255; curly.x=200; curly.y=200; larry= new Pisces(); larry.b=255; larry.x=300; larry.y=300; } void draw() { scene(); fish(); movefish(); showfish(); } void movefish() { // moe.move(); curly.move(); larry.move(); // } void showfish() { // moe.show(); curly.show(); larry.show(); // } void scene() { background(27, 247, 87); fishtank (); } void fishtank() { fill(77, 112, 247); stroke(1); strokeWeight(5); rectMode(CORNERS); rect(left,top,right,bottom); } void fish() { if (fishX
right) fishDX= -fishDX; if (fishY
bottom) fishDY= -fishDY; fishDY= fishDY + random( -0.05, +0.075 ); if (abs(fishDY) > 10) fishDY /= 10; fishX += fishDX; fishY += fishDY; // show strokeWeight (1); fill(255,255,0); ellipse(fishX,fishY,45,20 ); } class Pisces { //// Fish moves, draws, etc. float x=50, y=50; float dx=3, dy=2; int r, g, b; // METHODS // void move() { if (x
right) dx= -dx; if (y
bottom) dy= -dy; dy= dy + random( -0.05, +0.075 ); if (abs(dy) > 10) dy /= 10; x += dx; y += dy; } // show void show() { strokeWeight (1); fill(r,g,b); ellipse(x,y,45,20 ); } }