Loading a random image for every different screen in Processing

Hi everyone!
Please note that I am a beginner :slight_smile:
I am trying to find how to change the background to a different image every time the screen changes. A bit of context: I am trying to make a quiz game, and every time I click on an answer, the screen changes. With the screen changing to a different question, I want to change the background as well. There will be 10 questions so I have 10 images.

So far, I am just mapping out the process on paper, basically, how should I tackle it step by step, but I am stuck on this one. Just looking for some orientation. Thank you!

Hi @onosecond,

There are several approaches…

For sure you have already a counter which says on which question the game is, right ?

Given that, you can either load your 10 images to an array in setup and display the background image corresponding to that counter variable.


you can name your images in the data folder ie.
back_1.jpg, back_2.jpg,…,back_N.jpg
and load the corresponding image if the counter changes and display it.

— mnse