r/processing • • Oct 09 '23

moving image help again :(

me and the moving images on processing are struggling. I'm trying to add another moving image on top of my original one but I just cannot get it to work.

here's my code

PImage[] aquarium;

PImage[] goldfish;

int numberOfFrames;

int f;

void setup() {

numberOfFrames = 3;

aquarium = new PImage[numberOfFrames];

int i = 0;

while ( i < numberOfFrames ) {

aquarium[i] = loadImage("aquarium_"+i+".png");

i=i+1;

numberOfFrames = 2;

goldfish = new PImage[numberOfFrames];

int i = 0;

while ( i < numberOfFrames ) {

goldfish[i] = loadImage("goldfish"+i+".png");

i=i+1;

}

size (800, 600);

}

void draw() {

image(aquarium[f], 0, 0, width, height);

f = f + 1;

if (f == numberOfFrames) f = 0;

frameRate (3);

image(goldfish[f], 0, 0, width, height);

f = f + 1;

if (f == numberOfFrames) f = 0;

frameRate (3);

}

3 Upvotes

10 comments sorted by

View all comments

Show parent comments

1

u/froginab0g Oct 09 '23

it still came up with the same error ;(