# Updating after a some time on all frameCounts?

**URL:** <https://discourse.processing.org/t/updating-after-a-some-time-on-all-framecounts/41935>\
**Category:** Beginners\
**Created:** [May 7, 2023, 12:51pm UTC](https://discourse.processing.org/t/updating-after-a-some-time-on-all-framecounts/41935 "2023-05-07T12:51:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aryszin](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Aryszin](https://discourse.processing.org/u/Aryszin)\
**Post date:** [May 7, 2023, 12:51pm UTC](https://discourse.processing.org/t/updating-after-a-some-time-on-all-framecounts/41935/1 "2023-05-07T12:51:56Z")

</div>

Is this code fine for every frame count? it doesntned to be super accurate

```auto
void updateInterval() {
  updatingIntervalCounter++;
  updateNow = false;
  if (updatingIntervalCounter > frameRate/8) {
    updatingIntervalCounter = 0;
    updateNow = true;
  }
}

```

Thank you guys 😊

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [May 7, 2023, 1:00pm UTC](https://discourse.processing.org/t/updating-after-a-some-time-on-all-framecounts/41935/2 "2023-05-07T13:00:53Z")

</div>

> [@Help with simple game (moving fish)](http://discourse.processing.org/t/help-with-simple-game-moving-fish/40679/5):
>
> For time we can use millis() or frameCount: If you pick frameCount, remember that draw() is called back around 60 FPS. So, if you wish for your fish to turn around between 5 to 10 seconds you could use this: nextFrameChange = frameCount + (int) random(5 \* 60, 10 \* 60); Then keep polling the value of frameCount until it reaches nextFrameChange: if (frameCount \>= nextFrameChange) swapDirection();

> [@Help with simple game (moving fish)](http://discourse.processing.org/t/help-with-simple-game-moving-fish/40679/9):
>
> You pick another value for nextFrameChange only after frameCount reached current nextFrameChange: if (frameCount \>= nextFrameChange) swapDirection(); It’s inside funtion swapDirection() that you change nextFrameChange: void swapDirection() { speed \*= -1; nextFrameChange = frameCount + 60 \* (int) random(5, 11); // 5s to 10s range } Anyways, I did a demo sketch that has a class Fish w/ methods such as display(), update(), bounce(), touchedBoundary(), etc.: Swimming\_Fish.pde /\*\* \* Swim…
