How can i collect coins very fast,?


#1

i want to use ‘’’ move(item.pos)’’’ to collect coins,however the code below which i wrote to collect coins worked freaking weird!!!

the yellow man stumbled a lot like he was so confusing which coin should he pick first!!

the time he hesitated could collect 100000 coins !

omg,i am pissed !!!

‘’‘
loop {

var coins=this.findItems();
var coinIndex=0;
while (coinIndex<coins.length) {
    var coin=coins[coinIndex];
    
        this.move(coin.pos);
    
    coinIndex++;
}

’‘’

please, friends who knows how and why please tell my how and why !!

i would be really thankful to you !!!


#2

Check out the difference betwen move() and moveXY(), they don’t work the same.
Regarding your code, i’d do :

loop {
var coin = this.findNearest(this.findItems());
if(coin) this.move(coin.pos);
else break;
}

That would do what you want (collect all the coins)


#3

I had the same experience at one point. The “move” command takes one step in the target’s direction, then executes the rest of the code. The only way to use it effectively, as pixx said, is to use findNearest instead of an array.


#4

hey!!!it worked effectively!!!

thanks to you !!!

is that thanks to you or thank to you …

i mean it’s you i get it .

(^o^)/~~~ happy~~~


#5

thanks!!!

i get it!!!!

hahahahahha ~~~