I cant seem to find the error in my code. It says that right is not a function
# Escape from the maze!
# Some doors are blocked, some open when you are near them.
intersection = []
dbr = 16
startRoom = {"x": 18, "y": 19}
def right():
if hero.isPathClear(hero.pos, {"x" : hero.pos.x + dbr,"y" : hero.pos.y}):
return 1
return 0
def up() :
if hero.isPathClear(hero.pos, {"x" : hero.pos.x,"y" : hero.pos.y + dbr}):
return 1
return 0
def down() :
if hero.isPathClear(hero.pos, {"x" : hero.pos.x,"y" : hero.pos.y - dbr}):
return 1
return 0
def left() :
if hero.isPathClear(hero.pos, {"x" : hero.pos.x - dbr,"y" : hero.pos.y}):
return 1
return 0
while True:
right = right()
up = up()
left = left()
down = down()
if (right + up + left + down) >= 2 :
#si j'ai un choix je dois noter l'intersection
intersection.append(hero.pos)
if up == 1:
hero.moveXY(hero.pos.x, hero.pos.y + dbr)
elif right == 1:
hero.moveXY(hero.pos.x+dbr, hero.pos.y)
elif left == 1:
hero.moveXY(hero.pos.x-dbr, hero.pos.y)
elif down == 1:
hero.moveXY(hero.pos.x, hero.pos.y-dbr)
if (right + up + left + down) == 0:
for i in range(len(intersection)) :
if hero.isPathClear(hero.pos, intersection[i]):
hero.moveXY(intersection[i].x, intersection[i].y)
elif right == 1:
hero.moveXY(hero.pos.x+dbr, hero.pos.y)
elif up == 1 :
hero.moveXY(hero.pos.x, hero.pos.y+dbr)
elif down == 1 :
hero.moveXY(hero.pos.x, hero.pos.y-dbr)
elif left == 1 :
hero.moveXY(hero.pos.x-dbr, hero.pos.y)