[SOLVED] Drop The Flag Level Help in Backwoods Forest

Okay, this helped a lot.

Thank you!!

2 Likes

The code is self.(I HATE CODE)

2 Likes

yes please.
sorry i have been playing code combat for a while and stopped for a while when I got to this level.
then i came back to see if there was something i missed, until i found this email and thought id ask you for some help. my code is starting to confuse me and I wanted to get some guidance from you on this topic.

2 Likes

cuold you give me one too?

2 Likes

What does your code look like? Maybe try pasting it here in the thread for people to look at :slight_smile:

2 Likes

nick, can you help? my code like this,but i cannot pass the level

loop:
    flag = self.findFlag()
    if flag:
        # How do we get fx and fy from the flag's pos?
        # (Look below at how to get x and y from items.)
        flagPos = flag.pos
        fx = flagPos.x
        fy = flagPos.y
        self.buildXY("fence", fx, fy)
        self.pickUpFlag(flag)
    else:
        item = self.findNearestItem()
        if item:
            itemPos = item.pos
            itemX = itemPos.x
            itemY = itemPos.y
            self.moveXY(itemX, itemY)
    

the result is like this ,i already collect all the coins,but i cannot pass the level?

2 Likes

You’re not creating fire-trap objects, you’re creating fences. The Ogres aren’t defeated, they’re just blocked.

Change self.buildXY(“fence”, fx, fy) to self.buildXY(“fire-trap”, fx, fy) and watch the fireworks. :smile:

3 Likes

thank you, i get it.

2 Likes

ok cool. i will hold on let me log into code combat

2 Likes
loop:
    flag = self.findFlag()
    if flag:
        # How do we get fx and fy from the flag's pos?
        # (Look below at how to get x and y from items.)
        
        var fx= 
            
        self.buildXY("fire-trap", fx, fy)
        self.pickUpFlag(flag)
    else:
        item = self.findNearestItem()
        if item:
            itemPos = item.pos
            itemX = itemPos.x
            itemY = itemPos.y
            self.moveXY(itemX, itemY)
  • > List item
2 Likes

ok i have been working and my code still doesnt work

loop:
    flag = self.findFlag()
    if flag:
        flagPos = flag.pos
        fx = flagPos.x
        fy = flagPos.y
        self.buildXY("fire trap", fx, fy)
        self.pickUpFlag(flag)
    else:
        item = self.findNearestItem()
        if item:
            itemPos = item.pos
            itemX = itemPos.x
            itemY = itemPos.y
            self.moveXY(itemX, itemY)
2 Likes

explain what is “not working” …details.

2 Likes

figured it out. it was probobly a glitch

2 Likes

can you help me with with rich forager

2 Likes

I did what you said how ever my character does what i need him to do but after placing the trap and picking up the flag he poops out a random trap somewhere

2 Likes

Can i see your code? I still can’t figure mine out:(

2 Likes

which level are you on?

2 Likes
loop:
    flag = self.findFlag()
    if flag:
            flagPos = flag.pos
            flagX = flagPos.x
            flagY = flagPos.y
            self.buildXY("fire-trap", flagX, flagY)
            self.pickUpFlag(flag)
    else:
        item = self.findNearestItem()
        if item:
            itemPos = item.pos
            itemX = itemPos.x
            itemY = itemPos.y
            self.moveXY(itemX, itemY)
2 Likes

XD Omg, thanks so much!

2 Likes

I need some help with this also

2 Likes