I am stuck. This is my code not sure what to do. Any suggestions? Thanks
# When you're not building traps, pick up coins!
loop:
flag = self.findFlag()
if flag:
# How do we get fx and fy from the flag's pos?
self.pickUpFlag(flag)
fx, fy = 30, 47
fx, fy = 30, 31
self.buildXY("fire-trap", fx, fy)
else:
item = self.findNearestItem()
if (item):
pos = item.pos
itemX = pos.x
itemY = pos.y
self.moveXY(itemX, itemY)
Now you are defining fx to be the position, then you are assigning a new value of 30. Then you assign 30 to it again. Your code will always build the trap at (30, 32).
Delete the two fx, fy = ?, ? lines of code and it should work fine.
I tried this and it still dosen’t work. Do you know how to fix it? (code below)
loop:
flag = self.findFlag()
if flag:
itemII = self.findNearestItem()
# How do we get fx and fy from the flag's pos?
# (Look below at how to get x and y from items.)
if itemII.type = "flag":
flagPos = self.findNearestItem()
fx = flagPos.x
fy = flagPos.y
self.buildXY("fire-trap", x, y)
self.pickUpFlag(flag)
else:
item = self.findNearestItem()
if item:
itemPos = item.pos
itemX = itemPos.x
itemY = itemPos.y
self.moveXY(itemX, itemY)