Lost viking... .py


#1

sooo…
I’m doing: https://codecombat.com/play/level/lost-viking
and… Well I don’t understand it at all and kinda makes me disappointed in myself,
how do I add new values too old values correctly…
Where do they learn you that,
Like I got it to move with:

SLIDE=9
SWITCH=5
SKIP=7
sidemove = 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):
        sidemove -= 1;
    sideSteps += sidemove
    if (steps % SKIP == 0):
        sideSteps += sidemove
    if (sideSteps > SLIDE):
        sideSteps -= SLIDE;
        if (sideSteps < 1):
            sideSteps += SLIDE;
    steps += 1

but it just ends up walking into the mines…
I’ve no understanding of how the mission works, Even with the “hints”…
I feel like I’ve missed a huge part of this game some how…?
this is what it looks like https://s.put.re/kXsyYN8.gif


#2

It has been a while and no one has given me any help yet…


#3

Level is really hard
I was planning to help you
but
Even considering that I finished the level
I look at my code, and not particularly understand what he is doing


#4

switch - manage hero.pos.y

sideSteps++
until switch, then
sideSteps–
until switch, then
sideSteps++
until switch, then
sideSteps–
etc

skip - manage hero.pos.y, relative current switch

sideSteps++
sideSteps++
or
sideSteps–
sideSteps–

slide - manage hero.pos.y, limiter

sideSteps > slide
reset sideSteps to the 1
sideSteps < 1
reset sideSteps to the slide

We need

  1. mechanism to Switch between sideStep++ and sideStep–
  2. mechanism to execute Skip regarding current Switch
  3. limiter for max and min sideStep

regarding your code
You have no 1
have part of 2
and have 3

sidemove = 1
if (steps % SWITCH == 0):
        sidemove -= 1;

sidemove = 1 - 1 = 0
sideSteps += 0
gorizontal move until next switch