# Weird moving of the hero

**URL:** <https://discourse.codecombat.com/t/weird-moving-of-the-hero/1916>\
**Category:** Uncategorized\
**Created:** [December 15, 2014, 9:00pm UTC](https://discourse.codecombat.com/t/weird-moving-of-the-hero/1916 "2014-12-15T21:00:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SOnick](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@SOnick](https://discourse.codecombat.com/u/SOnick)\
**Post date:** [December 15, 2014, 9:00pm UTC](https://discourse.codecombat.com/t/weird-moving-of-the-hero/1916/1 "2014-12-15T21:00:29Z")

</div>

I cant understand what`s wrong with my hero moving code?

```javascript
loop {
    // Find coins and/or attack the enemy.
    // Use flags and your special moves to win!
    var items = this.findItems();    

    for (var a = 0; a < items.length; ++a) {
    
        var enemy = this.findEnemies();  
        if (enemy.length > 0) {
            for (var i = 0; i < enemy.length; ++i) {
                var enemy1 = enemy[i];
                this.attack(enemy1);
            }
        } else {
            var item = items[a];
            this.move({x: item.pos.x, y: item.pos.y});
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![jwrobbs](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/jwrobbs/32/1673_2.png) [@jwrobbs](https://discourse.codecombat.com/u/jwrobbs)\
**Post date:** [December 15, 2014, 9:09pm UTC](https://discourse.codecombat.com/t/weird-moving-of-the-hero/1916/2 "2014-12-15T21:09:36Z")

</div>

You need to be more descriptive. What is your hero doing?

---

<div class="post-metadata">

**Author:** ![sotonin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sotonin/32/24089_2.png) [@sotonin](https://discourse.codecombat.com/u/sotonin)\
**Post date:** [December 15, 2014, 9:13pm UTC](https://discourse.codecombat.com/t/weird-moving-of-the-hero/1916/3 "2014-12-15T21:13:17Z")

</div>

It’s the “move” method. it’s currently bugged. i recommend switching back to boots with moveXY

---

<div class="post-metadata">

**Author:** ![SOnick](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@SOnick](https://discourse.codecombat.com/u/SOnick)\
**Post date:** [December 15, 2014, 9:14pm UTC](https://discourse.codecombat.com/t/weird-moving-of-the-hero/1916/4 "2014-12-15T21:14:22Z")

</div>

This is a "multiplayer treasure grove"  
My hero should collect coins and kill all enemies.

---

<div class="post-metadata">

**Author:** ![sotonin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sotonin/32/24089_2.png) [@sotonin](https://discourse.codecombat.com/u/sotonin)\
**Post date:** [December 15, 2014, 9:54pm UTC](https://discourse.codecombat.com/t/weird-moving-of-the-hero/1916/5 "2014-12-15T21:54:49Z")

</div>

He meant describe what was wrong with your heros movement. nonetheless i already gave you the answer. 🙂
