# Stuck on Oasis Level

**URL:** <https://discourse.codecombat.com/t/stuck-on-oasis-level/11495>\
**Category:** Uncategorized\
**Created:** [May 21, 2017, 6:23pm UTC](https://discourse.codecombat.com/t/stuck-on-oasis-level/11495 "2017-05-21T18:23:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luke10](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/luke10/32/19892_2.png) [@Luke10](https://discourse.codecombat.com/u/Luke10)\
**Post date:** [May 21, 2017, 6:23pm UTC](https://discourse.codecombat.com/t/stuck-on-oasis-level/11495/1 "2017-05-21T18:23:23Z")

</div>

Hey guys sorry to bug you but I can’t figure this one out. My code seems to be right but it says I am not defining `x`. Here is my code.

```python
while True:
    newX = hero.pos.x 
    newY = hero.pos.y
    enemy = hero.findNearestEnemy()
    if enemy and hero.distanceTo(enemy) < 10:
        # Subtract 10 from x to move left.
        hero.moveXY(x - 10, y)
        # Use moveXY to move to the new x, y position.
        hero.moveXY(newX, newY)
        pass
    else:
        # Add 10 to x to move right.
        hero.moveXY(x + 10, y)
        # Use moveXY to move to the new x, y position.
        hero.moveXY(newX, newY)
        pass

```

Help would be appreciated

Thanks!

---

<div class="post-metadata">

**Author:** ![Hellenar](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellenar/32/9100_2.png) [@Hellenar](https://discourse.codecombat.com/u/Hellenar)\
**Post date:** [May 21, 2017, 9:49pm UTC](https://discourse.codecombat.com/t/stuck-on-oasis-level/11495/2 "2017-05-21T21:49:21Z")

</div>

Do you mean to use `newX` instead of `x`? 😉

---

<div class="post-metadata">

**Author:** ![BobBobson412](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bobbobson412/32/6871_2.png) [@BobBobson412](https://discourse.codecombat.com/u/BobBobson412)\
**Post date:** [May 23, 2017, 11:37am UTC](https://discourse.codecombat.com/t/stuck-on-oasis-level/11495/3 "2017-05-23T11:37:38Z")

</div>

The same applies for y you are using x and y which aren’t defined try either defining x and y or using newX and newY instead.

---

<div class="post-metadata">

**Author:** ![\_TD\_RodYT](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/_td_rodyt/32/6285_2.png) [@\_TD\_RodYT](https://discourse.codecombat.com/u/_TD_RodYT)\
**Post date:** [May 24, 2017, 4:54pm UTC](https://discourse.codecombat.com/t/stuck-on-oasis-level/11495/4 "2017-05-24T16:54:51Z")

</div>

First add 10 to newX with += to find where you need to move.  
Then, you could use something like `hero.moveXY(newX, newY)`.
