Created
September 29, 2016 06:18
-
-
Save CallumHoward/b55614c5fbf6d8e74d3958e04c33ea04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int num = 50; | |
int[] x = new int[num]; | |
int[] y = new int[num]; | |
ArrayList<Fish> fishies = new ArrayList<Fish>(); | |
void setup() { | |
size(500, 500); | |
noStroke(); | |
fill(255, 102); | |
// add some fish | |
for (int i = 0; i < num; ++i) { | |
fishies.add(new Fish(int(random(50)), int(random(50)), #FFFFFF)); | |
} | |
} | |
void draw() { | |
background(0); | |
// Shift the values to the right | |
for (int i = num-1; i > 0; i--) { | |
x[i] = x[i-1]; | |
y[i] = y[i-1]; | |
} | |
// Add the new values to the beginning of the array | |
x[0] = mouseX; | |
y[0] = mouseY; | |
fishies.add(new Fish(x[0], y[0], #FFFFFF)); | |
// Draw the fish | |
for (int i = 0; i < num; i++) { | |
Fish f = fishies.get(i); | |
f.drawFish(); | |
} | |
fishies.remove(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment