[SOLVED] Help with Slalom


#1

Hello, I am having a lot of trouble with the level slalom, this is my code and after line 8 he just walks off into the cliff.

while hero.pos.x < 20:
	hero.move({'x': 20, 'y': 35})
while hero.pos.x < 25:
	hero.move({'x':25, 'y': 25})
while hero.pos.x < 30:
    hero.move({'x':30, 'y': 35})
while hero.pos.x < 35:
    hero.move({'x':35, 'y': 25})
while hero.pos.x < 40:
    hero.move({'x':40, 'x': 35})
while hero.pos.x < 45:
    hero.move({'x':45, 'y': 25})
while hero.pos.x < 50:
    hero.move({'x':50, 'y': 35})
while hero.pos.x < 55:
    hero.move({'x':55, 'y': 25})

P.S. I probably won"t respond until tomorrow as that I have to go to bed.


#2

That isn’t really how the level is meant to be done, you need to move to the gems poses not just x, y poses as shown in the original code:


First the code moves to 20, 35, then it moves to the gem using move to go to its .pos: hero.move(gem0.pos). Next, using the same base as the first piece of code:

while hero.pos.x < 20:
	# move() takes objects with x and y properties, not just numbers.
	hero.move({'x': 20, 'y': 35})

You have to follow the instructions: “While your x is less that 30, use an object to move to 30, 35.” Objects are explained in the hints, replace what it has in the first bit of code with the information in the instructions for the first bit you have to write: “While your x is less that 30, use an object to move to 30, 35.” . Now look at the second bit of code and the instructions of the second bit you have to write: # While your x is less than 35, move to the position of gems[1]. and write the second bit of code out again:

while hero.pos.x < 20:
	# move() takes objects with x and y properties, not just numbers.
	hero.move({'x': 20, 'y': 35})

and replace the information in it with the information in the above instructions: # While your x is less than 35, move to the position of gems[1].
Sorry for the long and messy reply, I hope it helps! if not please say what specifically you don’t understand, Thanks. Also make sure to read the hints carefully.


#3

Thank you it worked and I finished the level


#4

Cool. :grin: ( 20 chars )