Lost Viking Level Help

I’m very confused about the Lost Viking level, I need some help!
I’ve read all the other post about Lost Viking but still confused.
Can anyone explaine to me about this level
Thanks

Hi Ufy,

Welcome to the forum!

First thing to say is that Lost Viking is way more complicated than the other levels around it. If you’re new to coding then maybe leave it for now and come back to it. I had a look at it 3 or 4 times, and I didn’t complete it until I was on the mountain levels.

However, you asked so I’ll try to answer. You’re trying to write code so that the path the hero takes follows the line of flowers between the mines. You start by writing a loop based on ‘steps’, which looks something like:

        hero.moveXY(steps * X_PACE_LENGTH, sideSteps * Y_PACE_LENGTH);
        steps++;
        sideSteps++;

This will take you on a diagonal line, going up. (If you try it, you’ll find you hit a mine after a few steps). The instructions then give things that you have to do to modify this loop (based on Slide, Skip and Switch). If you get these modifications right, your hero will move along the wiggly path right to the end. It’s quite hard to work out the order of these modifications so they all happen at the right time. To start, take them one at a time, and think about what you’re being asked to do, and what that would look like as code.

Expect to try it lots and lots of times to get it right (or maybe if you’re good at programming then it’s easier than that!), but it’s pretty satisfying when it finally works. Good luck :smile:.

2 Likes

slide = 10
skip = 11
switch = 7
s = 1

sidesteps = 1

steps = 1
X_PACE_LENGTH = 4

Y_PACE_LENGTH = 6

while steps <= 35:
hero.moveXY(steps * X_PACE_LENGTH, sidesteps * Y_PACE_LENGTH)
if steps % switch == 0:
s=-s
if steps % skip == 0:
sidesteps += s
sidesteps+= s
if sidesteps < 1:
sidesteps = slide
if sidesteps > slide:
sidesteps = 1
steps += 1