# On game update and forever

**URL:** <https://forum.makecode.com/t/on-game-update-and-forever/24102>\
**Category:** Arcade\
**Created:** [November 9, 2023, 5:46pm UTC](https://forum.makecode.com/t/on-game-update-and-forever/24102 "2023-11-09T17:46:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mega0star01](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mega0star01/32/14784_2.png) [@Mega0star01](https://forum.makecode.com/u/Mega0star01)\
**Post date:** [November 9, 2023, 5:46pm UTC](https://forum.makecode.com/t/on-game-update-and-forever/24102/1 "2023-11-09T17:46:09Z")

</div>

what’s the difference between “on game update” and “forever”?

---

<div class="post-metadata">

**Author:** ![ChimbroDaPro](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/chimbrodapro/32/15852_2.png) [@ChimbroDaPro](https://forum.makecode.com/u/ChimbroDaPro)\
**Post date:** [November 9, 2023, 7:13pm UTC](https://forum.makecode.com/t/on-game-update-and-forever/24102/2 "2023-11-09T19:13:05Z")

</div>

**idk**

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [November 9, 2023, 8:11pm UTC](https://forum.makecode.com/t/on-game-update-and-forever/24102/3 "2023-11-09T20:11:26Z")

</div>

Good question, @Mega0star01 !

At first glance, the two containers _do_ seem to serve similar roles. In general, you should use `on update` instead of `forever`. There are a lot of technical differences between the two containers, and the `on update` container is specifically designed for the MakeCode Arcade environment, whereas the `forever` container is used in other MakeCode environments (like micro:bit).

Code inside of a `forever` loop runs “in the background,” separately and independently from your game. These `forever` loops are great for things like background music.

Code inside of `on game update` loops runs frequently – usually each time the screen updates, but the MakeCode Arcade environment determines how frequently the code runs. This is where you put your code that needs to run each time “something” changes in your game.

Again, they are _really_ similar. Unless you actually need to use a `forever` loop, you should use an `on game update` loop in MakeCode Arcade.

For reference:

> **[on Update](https://arcade.makecode.com/reference/game/on-update)**
>
> Run game update code.

> **[forever](https://arcade.makecode.com/reference/loops/forever)**
>
> Run a part of the program in the background and keep running it over again.

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [November 9, 2023, 8:13pm UTC](https://forum.makecode.com/t/on-game-update-and-forever/24102/4 "2023-11-09T20:13:16Z")

</div>

An important thing to note is that the code in the `on game update` blocks _needs to finish_ before the game will update again. Here’s an example that uses a `forever` loop.

> **[forever](https://arcade.makecode.com/48441-69315-98668-98367)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

 ![arcade-screenshot (10)](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/e/e17a780e445f2125b33e6a21bc3f4eb412051082.png)

Now … what would happen if you changed this project to use an `on game update` loop instead? Give it a try and see what happens!

So, if you need a loop to run so that it does not interfere with your game, then use a `forever` loop. Otherwise, you probably should use an `on game update` loop instead.

---

<div class="post-metadata">

**Author:** ![Mega0star01](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mega0star01/32/14784_2.png) [@Mega0star01](https://forum.makecode.com/u/Mega0star01)\
**Post date:** [November 9, 2023, 8:41pm UTC](https://forum.makecode.com/t/on-game-update-and-forever/24102/5 "2023-11-09T20:41:45Z")

</div>

thank you @AlexK, well now it makes sense.
