Bug or Me? (Stranded in the Dunes - Automated) [Python]

Hi All,

Hoping someone can help me out here; trying to complete “Stranded in the Dunes” in Python and, whilst I don’t believe it’s a bug per se, I’m really not sure how to complete it without using flags.

The problem being that when I use self.pos.x+1 to move the character right, that’s all well and fine up until it hits the right border and the scene changes, but that currentPos = self.pos isn’t updating, because the last x point is held over from the previous screen.

This can be demonstrated in a particularly horrible and simple loop I used to narrow down the issue here:


loop:
    enemy = self.findNearestEnemy()

    if enemy:
        self.attack(enemy)
    else:
        currentPos = self.pos
        self.say(currentPos)
        self.moveXY(currentPos.x + 1, currentPos.y)


Without knowing how (or being able?) to edge detect, I’m not really sure how to do this level without using flags, which I was hoping to do.

Kind Regards,
WryZed

Get rid of the variable currentPos and just use self.pos. That way, the hero will be constantly updating its position and you shouldn’t have this problem.

Tried that already unfortunately:

loop:
    enemy = self.findNearestEnemy()

    if enemy:
        self.attack(enemy)
    else:
        self.moveXY(self.pos.x + 1, self.pos.y)

Same result.

I did actually manage to find “something” of a workaround, although not particularly elegant, which was this:

loop:
    enemy = self.findNearestEnemy()

    if enemy:
        self.attack(enemy)
    else:
        currentPos = self.pos
        self.say(currentPos)
        if currentPos.x > 117:
            self.moveXY(currentPos.x +0.4,currentPos.y)
            self.say("Hmm!") # Seems you need a pause here for the screen right transition kick in.
            self.moveXY(1,currentPos.y)
        else:
            self.moveXY(currentPos.x + 1, currentPos.y)

Which I’m not going to lie, is horrible, but going to expand on it a bit and see if it holds true to other screens as it progresses right.

Ok, so this actually works, which is the cleanest I can get it at this stage:

    else:
        if self.pos.x > 118:
            self.say("Next!") # Pause required to allow screen transition to right
        else:
            self.moveXY(self.pos.x + 1, self.pos.y)