# I think either makecode can not preview this code because it is too powerful or there is a bug

**URL:** <https://forum.makecode.com/t/i-think-either-makecode-can-not-preview-this-code-because-it-is-too-powerful-or-there-is-a-bug/2715>\
**Category:** Help\
**Created:** [July 9, 2020, 4:53pm UTC](https://forum.makecode.com/t/i-think-either-makecode-can-not-preview-this-code-because-it-is-too-powerful-or-there-is-a-bug/2715 "2020-07-09T16:53:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nobrain](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/nobrain/32/1078_2.png) [@Nobrain](https://forum.makecode.com/u/Nobrain)\
**Post date:** [July 9, 2020, 4:53pm UTC](https://forum.makecode.com/t/i-think-either-makecode-can-not-preview-this-code-because-it-is-too-powerful-or-there-is-a-bug/2715/1 "2020-07-09T16:53:30Z")

</div>

I was creating a survival game based on the Rain world videogame. I was trying too create an enemy plant that its purpose was to eat the main character. The plant was made by 5 points that were generated in specific places on the game. Then on game update another point was made to follow each of these plant points with a high speed alternately. If the character touched one of these plant points these plant points would follow the character, grab him and take him to the plants core so the plant could eat him. I made the following point part, but I didn’t finish the part where the plant grabs the character. The game would just get stuck and wouldn’t work. I can create games in other engines but I prefer coding in makecode because it is easier to use.

> **[Rain World](https://arcade.makecode.com/23832-39368-02006-24296)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [July 9, 2020, 5:19pm UTC](https://forum.makecode.com/t/i-think-either-makecode-can-not-preview-this-code-because-it-is-too-powerful-or-there-is-a-bug/2715/2 "2020-07-09T17:19:49Z")

</div>

The reason the game is freezing is because of this part of the code:

 ![Screen Shot 2020-07-09 at 10.04.21 AM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/0/0209e687daeb9504031da47ac0798d195d8dea76.png)

Could you explain what this code is trying to do? I might be able to point you in the right direction but I’m not sure I have a clear picture of what is supposed to happen.

The freezing is caused by the calls to `pause`. You should never call `pause` inside of an `on game update` event because that code needs to finish running before the screen can be drawn. Instead, use `forever` if you want to `pause`.

It also looks like you have a lot of nested loops here, but they are mostly doing the same thing. All of the plant parts have the same `kind` (which is Player) so each of these loops is trying to loop over the same list of sprites. Be careful here! If you were to remove the `destroy sprite` block at the end of the innermost loop then this code would try to run 8^6 times for every game update which would slow your game down quite a bit!

---

<div class="post-metadata">

**Author:** ![Nobrain](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/nobrain/32/1078_2.png) [@Nobrain](https://forum.makecode.com/u/Nobrain)\
**Post date:** [July 10, 2020, 1:44pm UTC](https://forum.makecode.com/t/i-think-either-makecode-can-not-preview-this-code-because-it-is-too-powerful-or-there-is-a-bug/2715/3 "2020-07-10T13:44:58Z")

</div>

plantParts are the plant points. The list is the point that follows the five plant points with high speed. If this happens on game update, there will be created a long line, because on every update a plantPart follower is going to be created, and it will follow each of these plant points alternately based on the number( so first the plantPart\_1 is going to be followed, than the plantPart\_2 and this happens until plantPoint\_follower reaches the plantPart\_5, that it will be destroyed). Many images were needed to make this plant without these points, because the whole body of the plant was supposed to follow the character, and I wanted that the plant would be good animated, so I found this as the easiest way.

---

<div class="post-metadata">

**Author:** ![felixtsu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/felixtsu/32/12024_2.png) [@felixtsu](https://forum.makecode.com/u/felixtsu)\
**Post date:** [July 12, 2020, 7:58am UTC](https://forum.makecode.com/t/i-think-either-makecode-can-not-preview-this-code-because-it-is-too-powerful-or-there-is-a-bug/2715/4 "2020-07-12T07:58:05Z")

</div>

I tried. First of all, change onGameUpdate to Forever with `pause()` clears all the game update halts. (`pause()` will yield in `forever()`)  
And then the next onGameUpadte with N_N_N_N_N\*… loop looks like a ‘on overlaps event’ to me.

> **[Rain World.modified](https://arcade.makecode.com/22320-04028-28506-90268)**
>
> 用❤️创造，Microsoft MakeCode Arcade出品。
