so my hero is just standing there and i really don’t know what im doing wrong. there are no errors in the code, she just isnt moving also i used some of the code from fragile maze.
# Find the treasure inside the maze.
# When you get the treasure, move to the exit.
# The exit is marked by the red cross. The level ends when you step on the mark.
# Some doors are blocked, some open when you are near them.
exitPosition = {"x": 150, "y": 120}
distanceBetweenRooms = 16
zeroShift = {"x": 10, "y": 10}
directions = ["left", "up", "right", "down"]
corrDir = {
"up": "left",
"left": "down",
"down": "right",
"right": "up"}
visited = []
def findNextDirection(current):
return directions[(directions.indexOf(current) + 1) % 4]
def pointInDirection(direction, pos):
if direction == "left":
return Vector(pos.x - distanceBetweenRooms, pos.y)
elif direction == "right":
return Vector(pos.x + distanceBetweenRooms, pos.y)
elif direction == "down":
return Vector(pos.x, pos.y - distanceBetweenRooms)
elif direction == "up":
return Vector(pos.x, pos.y + distanceBetweenRooms)
prev = "up"
while True:
tryDir = corrDir[prev]
while True:
tryPoint = pointInDirection(tryDir, hero.pos)
for visit in visited:
if visit == tryPoint:
findNextDirection(tryDir)
elif visit != tryPoint:
if hero.isPathClear(hero.pos, tryPoint):
treasure = hero.findNearestItem()
if treasure:
hero.moveXY(treasure.pos.x, treasure.pos.y)
hero.moveXY(exitPosition)
else:
hero.moveXY(tryPoint.x, tryPoint.y)
hero.moveXY(tryPoint.x, tryPoint.y)
visited.append(tryPoint)
break
tryDir = findNextDirection(tryDir)