# Devs: Python and the Arcade Engine Loop

**URL:** <https://forum.makecode.com/t/devs-python-and-the-arcade-engine-loop/28385>\
**Category:** Help\
**Created:** [April 23, 2024, 1:49am UTC](https://forum.makecode.com/t/devs-python-and-the-arcade-engine-loop/28385 "2024-04-23T01:49:31Z")\
**Posts on this page:** 3\
**Page:** 1

<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:** [April 23, 2024, 1:49am UTC](https://forum.makecode.com/t/devs-python-and-the-arcade-engine-loop/28385/1 "2024-04-23T01:49:31Z")

</div>

@richard , @jwunderl , & other devs: I’m seeking assistance. 😃 First of two threads.

In another thread[1], I was attempting to assist one of our forum members with Python and the project explorer. I started with a simple “chase and collect” game, which I created first in JavaScript.

> **[Simple Chase and Collect JS](https://arcade.makecode.com/45426-67084-07710-60928)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

I then tried to port the game (manually) to Python. I ended up with this, and now I’m confused. 😆

> **[Game Choice Python](https://arcade.makecode.com/45695-36140-62045-67690)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

I feel like the game engine loop is running separately (and independently) from the Python code that I’ve written. What it really feels like is that I’m misunderstanding something. Upon collision between the player and the enemy, shouldn’t the loop that moves the enemy away from the player complete before the next screen update?

I really feel like something is different because I needed to inject a `null` check in `MoveEnemy()`, where I did not need to do so in JavaScript … leading me to believe that I’m just misunderstanding or misinterpreting something.

Please fill in the gaps. 😁 What am I missing?

* * *

[1] [MakeCode Arcade Explorer Help](https://forum.makecode.com/t/makecode-arcade-explorer-help/28348)

---

<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:** [April 23, 2024, 7:25pm UTC](https://forum.makecode.com/t/devs-python-and-the-arcade-engine-loop/28385/2 "2024-04-23T19:25:37Z")

</div>

@AlexK you are experiencing one of the joys of python programming! Assigning global variables requires you to declare them inside of a global statement like so:

```python
def Game1_Start():
    global enemy_sprite, hero_sprite

```

---

<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:** [April 23, 2024, 8:12pm UTC](https://forum.makecode.com/t/devs-python-and-the-arcade-engine-loop/28385/3 "2024-04-23T20:12:11Z")

</div>

BAH!!! I always forget that with Python. I knew I was missing something! Thanks, @richard !
