# Help with simple game (moving fish)

**URL:** <https://discourse.processing.org/t/help-with-simple-game-moving-fish/40679>\
**Category:** Coding Questions\
**Created:** [January 22, 2023, 7:19pm UTC](https://discourse.processing.org/t/help-with-simple-game-moving-fish/40679 "2023-01-22T19:19:20Z")\
**Posts on this page:** 1\
**Showing post:** 5

<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:** [January 23, 2023, 3:05am UTC](https://discourse.processing.org/t/help-with-simple-game-moving-fish/40679/5 "2023-01-23T03:05:05Z")

</div>

> [@sara](#):
>
> And how do I make the amount of seconds random?

For time we can use **millis()** or _frameCount_:

> **[millis() / Reference](https://processing.org/reference/millis_.html)**
>
> Returns the number of milliseconds (thousandths of a second) since starting the sketch. This information is often used for timing animation sequences.

> **[frameCount / Reference](https://processing.org/reference/frameCount.html)**
>
> The system variable frameCount contains the number o frames displayed since the program started. Inside setup() the value is 0 and during the first iteration of draw it is 1, etc.

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();`

---

_[View the full topic](https://discourse.processing.org/t/help-with-simple-game-moving-fish/40679)._
