# Loading a random image for every different screen in Processing

**URL:** https://discourse.processing.org/t/loading-a-random-image-for-every-different-screen-in-processing/40004
**Category:** Coding Questions
**Created:** [December 3, 2022, 6:34am UTC](https://discourse.processing.org/t/loading-a-random-image-for-every-different-screen-in-processing/40004 "2022-12-03T06:34:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![onosecond](https://avatars.discourse-cdn.com/v4/letter/o/e274bd/32.png) [@onosecond](https://discourse.processing.org/u/onosecond)
#### Post date: [December 3, 2022, 6:34am UTC](https://discourse.processing.org/t/loading-a-random-image-for-every-different-screen-in-processing/40004/1 "2022-12-03T06:34:28Z")

</div>

Hi everyone!  
Please note that I am a beginner 🙂  
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!

---

<div class="post-metadata">

### Author: ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)
#### Post date: [December 3, 2022, 7:22am UTC](https://discourse.processing.org/t/loading-a-random-image-for-every-different-screen-in-processing/40004/2 "2022-12-03T07:22:34Z")

</div>

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.

or

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.

Cheers  
— mnse
