hero.buildXY("fire-trap", 64, 44)
hero.moveXY(68, 12)
hero.moveXY(44, 8) #obliger de bouger sur la croix pour récupérer les items
while True:
gem = hero.findNearest(hero.findItems())
if gem:
clear = hero.isPathClear(hero.pos, gem.pos)
if clear and hero.isPathClear(hero.pos, gem.pos):
hero.move(gem.pos)
else:
hero.move({'x': 68, 'y': 12})
bonjour j’aimerais savoir pourquoi si j’enlève la ligne “hero.moveXY(44, 8)” mon héro ne vas pas chercher les items en tenant compte des obstacles il reste a la pos XY(68,12), sachant que avec le moveXY(44,8) mon perso vas chercher les items et reviens au point XY(68,2) en tenant compte des obstacles…
ps : j’ai les lunettes portée infini…
English Translation:
hello I would like to know why if I remove the line “hero.moveXY (44, 8)” my hero will not look for the items taking into account the obstacles he remains at pos XY (68,12), knowing that with the moveXY (44.8) my character will look for the items and return to point XY (68.2) taking into account the obstacles…
ps: I have glasses with infinite range …
Tout d’abord, les lignes 7 et 8 testent la même chose … vous n’en avez pas besoin; avec vos déclarations de mouvement, vous placez le héros dans une ligne de vue claire.
Deuxièmement, vous devez parcourir toutes les gemmes, en vous déplaçant individuellement vers la position de chaque pièce.
English Translation:
First, lines 7 and 8 are testing for the same thing…you don’t need them; with your move statements, you are placing the hero in a clear line of view.
Second, you should iterate through all of the gems, moving to each coin’s position individually.
merci pour ta repose rapide
j’ai alléger le code avec vos conseille, c’est vrai que if item and hero.isPathClear(hero.pos, item.pos):
c’est plus logique…