Double Cheek - no coins spawning

Every time my character reaches the first set of coordinates, no coins begin to spawn. I was wondering if this was an error with my code or with the level. Here’s my code:

while defeatedOgres < 6:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)
        defeatedOgres += 1
    else:
        hero.say("Ogres!")

# Move to the right side of the map.
hero.moveXY(54, 36)

# This loop is executed while you have less than 30 gold.
while hero.gold < 30:
    # Find and collect coins.
    item = hero.findNearestItem()
    if item:
        hero.moveXY(item.pos.x, item.pos.y)
    # Remove this say() message.
    hero.say("I should gather coins!")



# Move to the exit.
hero.moveXY(76, 32)

Howdy and welcome to the forum!

The code you pasted is missing the declaration of defeatedOgres, but I’m assuming you just missed that when you copy and pasted. Otherwise, the only thing different is you did not remove/comment out the say statement on line 29. Even so, I ran the level with your code and it passed (after adding the declaration).

You can try Restarting the level (button on upper right)…make a copy of your code first, and just paste it back in and see how it goes.

see topic : [SOLVED] Help double cheek python

1 Like

@Ninja_Unicorn, post a screen shot of your game, at the point you move to the next coordinates. Xython may have a very good point here.

Okay, here’s the screenshot:

ok…see that last guy chasing you? I count only 3 obvious bodies (can’t tell if any are stacked on top of each other) and there must be 6 of them. The guy chasing is definitely not dead. Check out the link Xython provided and see if you can figure out how to remedy this.

All right. Thanks for the help!