What is wrong with this code?
Use isPathClear to move around the randomly positioned boulders.
Automatic pathfinding doesn’t work in Boulder Woods.
loop:
angle = Math.PI / 2 - Math.PI / 16
while angle >= -Math.PI / 2:
targetX = self.pos.x + 5 * Math.cos(angle)
targetY = self.pos.y + 5 * Math.sin(angle)
# Use isPathClear between your current pos and the target.
# If the path is clear, move to the target.
if self.isPathClear(targetX, targetY):
self.move({‘x’: targetX, ‘y’: targetY})
# Otherwise, sweep the angle clockwise a bit.
angle -= Math.PI / 16
else:
self.move({‘x’: targetX, ‘y’: targetY})
It says that there is an “Unexpected Token” on the second-to-last line with the “else:” statement on it. I know that this is a new level so is it me who has done this wrong or developers…? Help please!