# How to make more images appear over time?

**URL:** https://discourse.processing.org/t/how-to-make-more-images-appear-over-time/33194
**Category:** Coding Questions
**Created:** [October 31, 2021, 4:01pm UTC](https://discourse.processing.org/t/how-to-make-more-images-appear-over-time/33194 "2021-10-31T16:01:51Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![MoonAlien822](https://avatars.discourse-cdn.com/v4/letter/m/65b543/32.png) [@MoonAlien822](https://discourse.processing.org/u/MoonAlien822)
#### Post date: [October 31, 2021, 4:01pm UTC](https://discourse.processing.org/t/how-to-make-more-images-appear-over-time/33194/1 "2021-10-31T16:01:52Z")

</div>

hey right now there is only one “trash” image but i’m trying to make it so the amount of “trash” images is equal to score+1

here’s my code:

```auto
float trashX;
float trashY;

float boatX;
float boatY;

float ropelenght = 0;

float movingspeed = 10;

float time;

int score = 0;

PImage[] trash = new PImage[18];

PImage[] boat = new PImage[3];

int right = 1;
int left = 2;

int bag = 1;
int beer = 2;
int box = 3;
int coffee = 4;
int deodorant = 5;
int energy = 6;
int jar = 7;
int laundrydetergent = 8;
int milk = 9;
int milkshake = 10;
int paper = 11;
int pizza = 12;
int soda = 14;
int tin = 15;
int tuna = 16;
int waterbottle = 17;

int boati = 1;

int trashi = int(random(0, 18));

boolean rope = false;

void setup() {
	fullScreen();

	trashX = random(0, width);
	trashY = ((height / 2) / 2) * 3;

	boatX = width / 2;
	boatY = (height / 2) / 2;

	trash[bag] = loadImage("bag.png");
	trash[beer] = loadImage("beer.png");
	trash[box] = loadImage("box.png");
	trash[coffee] = loadImage("coffee.png");
	trash[deodorant] = loadImage("deodorant.png");
	trash[energy] = loadImage("energy.png");
	trash[jar] = loadImage("jar.png");
	trash[laundrydetergent] = loadImage("laundry detergent.png");
	trash[milk] = loadImage("milk.png");
	trash[milkshake] = loadImage("milkshake.png");
	trash[paper] = loadImage("paper.png");
	trash[pizza] = loadImage("pizza.png");
	trash[soda] = loadImage("soda.png");
	trash[tin] = loadImage("tin.png");
	trash[tuna] = loadImage("tuna.png");
	trash[waterbottle] = loadImage("water bottle.png");

	boat[right] = loadImage("boatright.png");
	boat[left] = loadImage("boatleft.png");
}

void draw() {
		background(#006994);
	
	trashX= trashX - random(random(-3, -0.1), random(0.1, 3)); trashY = trashY - 1;

				image(trash[trashi], trashX, trashY, 20, 20);

				image(boat[boati], boatX, boatY, 50, 20);

				textSize(32); fill(0); // Fill color black
				text("score:" + score, 40, 80);

				if (rope == true) {
					time = millis();
					if (boati == right) {
						stroke(#957D57);
					line(boatX + 10, boatY + 15, boatX + 10 + ropelenght, boatY + 15);
					ropelenght = ropelenght + 10;
							if (trashX < boatX + 10 + ropelenght && trashY <= boatY + 15 && trashY + 20 >= boatY + 15) {
								score++;
								trashX = random(0, width);
								trashY = ((height / 2) / 2) * 3;
								ropelenght = 0;
								time = 0;
								trashi = int(random(0, 18));
								rope = false;
							}

						}
						if (boati == left) {
							time = millis();
							stroke(#957D57);
					line(boatX, boatY + 15, boatX - ropelenght, boatY + 15);
					ropelenght = ropelenght + 10;
								if (trashX > boatX - ropelenght && trashY <= boatY + 15 && trashY >= boatY + 15) {
									score++;
									trashX = random(0, width);
									trashY = ((height / 2) / 2) * 3;
									ropelenght = 0;
									time = 0;
									trashi = int(random(0, 18));
									rope = false;
								}
							}
						}
						if (boatX - ropelenght <= 0 || boatX + 10 + ropelenght >= width) {
							ropelenght = 0;
							rope = false;

						}

						if (trashY <= 0) {
							score--;
							trashX = random(0, width);
							trashY = ((height / 2) / 2) * 3;
							ropelenght = 0;
							time = 0;
							trashi = int(random(0, 18));
							rope = false;

						}

					}

					void keyPressed() {
						if (key == 'a') {
							boati = left;
						}
						if (key == 'd') {
							boati = right;
						}
						if (key == ' ') {
							rope = true;
						}
					}

```

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [October 31, 2021, 6:50pm UTC](https://discourse.processing.org/t/how-to-make-more-images-appear-over-time/33194/2 "2021-10-31T18:50:40Z")

</div>

Remember that an array starts with 0

In theory when you have a for loop with for…… i \< upperBound you can increase this variable every 500  
milliseconds or so

In this for loop show the images from the array and use i for it
