[SOLVED] Star shower CoCo python

For some reason the hero goes to a mushroom it should go to the gems or coins Here is my code:

Could you please take a larger photo of the code? I can’t see it clearly

1 Like

Maybe it should be

if distance
    if item and item.type == "gem" or distance < 20:
1 Like

It says ran out of time

Ah, then it should be

if distance
    if item and distance < 20 or item.type == "gem":
1 Like

It steel says ran out of time

Oops I accidentally clicked solution

So you still don’t collect the coins?

1 Like

I collect coin but it does not say success it says ran out of time

You collect 3 coins and all the gems? Or only one coin?

1 Like

It only collects one coin and all gems

You have to check if the item type is a coin or a gem, if it is, then check if the hero’s distance to the item is less than 20.

if item:
    if item.type == "gem" or item.type == "coin":
        if hero.distanceTo(item) < 20:
            #move to the item

Say ran out of time

Could someone hlp plz!

@RangerGrant9307 (200000000)

Okay.
Why would you define itemX and itemY?
Cool trick:
just do hero.moveXY(item.pos.x, item.pos.y)

Here is my code

Oh!
I just went to the level.
You need to collect ALL gems, and close coins.
Here is some advice:
Find the nearest Item:
if item.type == ‘gem’
Move to it.
If item.type == ;coin’ and hero.distanceTo(items) < 20:
Move to the coin.