# Changing image background with given specific time

**URL:** https://discourse.processing.org/t/changing-image-background-with-given-specific-time/38186
**Category:** Beginners
**Tags:** homework
**Created:** [August 1, 2022, 1:51pm UTC](https://discourse.processing.org/t/changing-image-background-with-given-specific-time/38186 "2022-08-01T13:51:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![steven](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@steven](https://discourse.processing.org/u/steven)
#### Post date: [August 1, 2022, 1:51pm UTC](https://discourse.processing.org/t/changing-image-background-with-given-specific-time/38186/1 "2022-08-01T13:51:32Z")

</div>

I’m 3rd year college student and I need a help about changing the image background with given specific time.

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [August 1, 2022, 2:08pm UTC](https://discourse.processing.org/t/changing-image-background-with-given-specific-time/38186/2 "2022-08-01T14:08:10Z")

</div>

Hello,

There are lots of solutions out there for this… lots.

Think about how you may code a timer with the building blocks from the references below.

References:  
[https://processing.org/reference/millis\_.html](https://processing.org/reference/millis_.html)  
[https://processing.org/reference/frameCount.html](https://processing.org/reference/frameCount.html)  
[https://processing.org/reference/background\_.html](https://processing.org/reference/background_.html)

Also look these up if not yet familiar:  
[https://processing.org/reference/setup\_.html](https://processing.org/reference/setup_.html)  
[https://processing.org/reference/draw\_.html](https://processing.org/reference/draw_.html)

`:)`

---

<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: [August 1, 2022, 2:51pm UTC](https://discourse.processing.org/t/changing-image-background-with-given-specific-time/38186/3 "2022-08-01T14:51:56Z")

</div>

Hi @steven,

Pretty much everything listed you need by @glv.

Maybe some meta description…

```auto
On start
    Create an array with available images.
    Initialize variables for currentImageindex and nextUpdateTime with suitable values 

On draw loop
    check if currentTime >= nextUpdateTime
    If true
        increment currentImageindex mod size of image array
        add interval to nextUpdateTime
    set background using currentImageIndex on available images

```

Cheers  
— mnse
