The differences in move xy and move

In move you can tell it to go to a object it is useful for collecting items

Move xy it tells the exact location it is good for moving once

move is one single move so move is better in levels that the coins disappear move will change to the nearest whatever

I agree @riticmaster9087 it is useful for items that shift around

I would also say:
moveXY() cannot end, once you’ve commanded your hero to moveXY he/she won’t stop till he’s got there. Another important thing is that this interrupts troop commanding, while you’re moveXY()ing somewhere you troops don’t receive commands and so will stay still unless they’re still completing the last command you gave them.

move() makes loads and loads of teeny tiny movements. That’s why it can be interrupted by commanding troops, attacking enemies and anything else you could think of. Also, as you said, if you detect a new coin/enemy and it’s closer/better than the previous one (depending on your choosing function) then move will be able to change direction immediately and head for the new target. This can cause problems however… Be careful of the hero moving backwards and forwards between two targets that your hero is equally distant to. Your hero move towards one, then the other one becomes more important and the hero moves back. If you’ve experienced this and you don’t know what to do:

item = findBestItem(items)
if item:
    while hero.distanceTo(item) > 8: # or another number, as long as it's close enough
        hero.move(item.pos)

This does slightly inhibit move()s abilities, but the stuck inbetween two objects is much worse.
If you don’t know how to move to an XY coordinate with move() you can use object literals or Vectors().

location = {"x": 56, "y": 49}
while True:
    hero.move(location)

location = Vector(56, 49)
while True:
    hero.move(location)

Danny

4 Likes

I agree Vectors() are better but you need programicon V witch you need to clear summits gate