//here is my global variables:
int waterCurrent = 6;
PImage img;
int fishPositionX = 0;
//here is my setup:
void setup() {
size(600, 600);
colorMode(HSB);
smooth();
img = loadImage(“fishny.png”);
frameRate(30);
}
//here is my draw loop:
void draw() {
background(0);
noStroke();
imageMode(CORNER);
moveFish();
skinOfFish(10);
}
//here is what moves the fish???
void moveFish() {
fishPositionX = fishPositionX + waterCurrent;
if (fishPositionX > width) {
waterCurrent = waterCurrent*-1;
}
if (fishPositionX < -50) {
waterCurrent = waterCurrent *-1;
}
}
//here is the function that draws the fish
void skinOfFish(int numberOfDots) {
//why is translate moving the fish???
translate(fishPositionX, 200);
for ( int x = 0;x < 300; x=x + numberOfDots) {
for ( int y = 0; y < 200; y=y + numberOfDots) {
fill(random(0, 255), 200, 150);
frameRate(5);
rect(x, y, numberOfDots, numberOfDots);
noStroke();
ellipse(x, y, numberOfDots, numberOfDots);
image(img, -30, -80, 350, 400);
stroke(1);
fill(0);
ellipse(225, 110, 20, 20);
fill(random(0, 255), 200, 150);
ellipse(225, 110, 10, 10);
}
}
}
