Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[Solved] Drop the Flag in Forest


#1

Hey guys i need help with my code for this if you can help PLEASE DO. im using Python

while True:
    
    flag = self.findFlag()
    if flag:
        # How do we get fx and fy from the flag's pos?
        flagpos = flag.pos
        fx = pos.x
        fy = pos.y
        
        
        self.buildXY("fire-trap", fx, fy)
        self.pickUpFlag(flag)
    else:
        item = self.findNearestItem()
        if item:
            pos = item.pos
            itemX = pos.x
            itemY = pos.y
            self.moveXY(itemX, itemY)```

#2

You’ve not properly defined fx and fy. Hint: Immediately above it you define, flagpos, but never use this variable.


#3

ohh ok thx i will fix that. THX SO MUCH


#4

you can also say “self.buildXY(“fire-trap”, flag.pos.x, flag.pos.y)”