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
Maybe it should be
if distance if item and item.type == "gem" or distance < 20:
It says ran out of time
Ah, then it should be
if distance if item and distance < 20 or item.type == "gem":
It steel says ran out of time
Oops I accidentally clicked solution
So you still don’t collect the coins?
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?
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
Could someone hlp plz!
Why would you define itemX and itemY?
just do hero.moveXY(item.pos.x, item.pos.y)
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.