[SOLVED] Mad Maxer.... Why are there so many? (Sells Out (Help))

// Coins here disappear after a few seconds!
// Get all the gold coins before they vanish.

while(true) {
    var closestGold = null;
    var minGoldDist = Infinity;
    var coinIndex = 0;
    var coins = hero.findItems();
    // Find the closest coin that is gold.
    // Remember that gold coins have a value of 3.
    while (coinIndex < coins.length){
    var coin = coins[coinIndex];
    var distance = hero.distanceTo(coin);
    if (coin.value == 3 && distance < minGoldDist){
        //here make closestCoin to be coin
        //here make minGoldDist to be distance
    }
    coinIndex++;
}
    if(closestGold) {
        // Now go to the closest gold coin and get it!
        hero.moveXY(closestGold.pos.x,closestGold.pos.y);
    }
}
2 Likes

I think the placeholder in java is return;

2 Likes

Here do what the comments I gave you tell you to do.

Andrei

2 Likes

here you need

closestCoin = coin
minGoldDist = distance

i think this is what @AnSeDra was trying to tell you about.

1 Like

That’s right!

Andrei

1 Like

does it work @Monsty?

1 Like

Thanks a lot @AnSeDra and Oliver!!!

2 Likes

No problem! And congratulations for completing the level! :partying_face:

Andrei

2 Likes
        closestGold = coin;
        minGoldDist = distance;

2 Likes

(as @AnSeDra would say) No problem! And congratulations on competing the level! :partying_face:

1 Like

Now I need help on 3 more levels.

It’s ok though I’ve finished (more than) enough for today!!

I’m supposed to do 3 levels a day

Why are you supposed to do 3 levels per day?

Andrei

1 Like

My dad told me to(20)

1 Like

Oh, ok. I was doing a lot of levels per day because I love this game. :grin:

Andrei

Me too!!!(20)

1 Like

Ok. We all might love Code Combat because it is such a good game that teaches informatics.

1 Like

same here (20 chars)!!

1 Like

Let’s now stick to the topic’s meaning that is the level Mad Maxer Sells Out.

Andrei