Hey Belton,
Here's what I came up with.
Notice it draws all the tails, and then all the images.
Processing layers things in the order they are drawn. For example, image 4 will always be below image 5;
Quote:import processing.opengl.*;
MyImage[] images;
void setup()
{
size(640, 480, OPENGL); //size of window and render mode
images = new MyImage[10];
images[0] = new MyImage(5,8,60,40,30,"0.gif");
images[1] = new MyImage(9,2,60,40,30,"1.gif");
images[2] = new MyImage(2,6,60,40,30,"2.gif");
images[3] = new MyImage(4,3,60,40,30,"3.gif");
images[4] = new MyImage(6,9,60,40,30,"4.gif");
images[5] = new MyImage(7,4,60,40,30,"5.gif");
images[6] = new MyImage(5,6,60,40,30,"6.gif");
images[7] = new MyImage(8,7,60,40,30,"7.gif");
images[8] = new MyImage(3,1,60,40,30,"8.gif");
images[9] = new MyImage(1,5,60,40,30,"9.gif");
}
void draw()
{
background(33);
frameRate(15);
update();
display();
}
void update(){
for(int i = 0; i < images.length; i++){
images[i].update();
}
}
void display(){
noStroke();
for(int i = 0; i < images.length; i++){
images[i].drawTail();
}
for(int i = 0; i < images.length; i++){
images[i].drawImg();
}
}
class MyImage{
int[][] pos;
int dx;
int dy;
int w;
int h;
int l;
PImage img;
MyImage(int dx, int dy, int w, int h, int l, String imgName){
this.dx = dx;
this.dy = dy;
this.w = w;
this.h = h;
this.l = l-1;
pos = new int[this.l+1][2];
img = loadImage(imgName);
}
void update(){
checkBounds();
shiftPos();
addPos();
}
void drawTail(){
for(int i = 0; i < l; i++){
fill(255,255*i/l);
rect(pos[i][0],pos[i][1],w*i/l,h*i/l);
}
}
void drawImg(){
image(img,pos[l][0],pos[l][1]);
}
private void checkBounds(){
if(pos[l][0] < 0 || pos[l][0] > width-w)
dx*=-1;
if(pos[l][1] < 0 || pos[l][1] > height-h)
dy*=-1;
}
private void shiftPos(){
for(int i = 1; i < l+1; i++){
pos[i-1][0] = pos[i][0];
pos[i-1][1] = pos[i][1];
}
}
private void addPos(){
pos[l][0] = pos[l-1][0]+dx;
pos[l][1] = pos[l-1][1]+dy;
}
}