Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Lost Viking Maze(JavaScript)

I’ve decided to bite the bullet and attempt the Lost Viking level in the forest. I’ve put my code in the spoiler below, but what happens is my character runs straight up into the nearest bomb. Any clue why she might be doing this?

Full Code Below
function moveSouth(){
    if(steps % skip === 0){
        sideSteps -= 2;
    }else{
        sideSteps--;
    }
}

function moveNorth(){
    if(steps % skip === 0){
        sideSteps += 2;
    }else{
        sideSteps++;
    }
}

// The maze is 35 steps along the X axis.
while(steps <= 35) {
    // Take the next step:
    hero.moveXY(steps * X_PACE_LENGTH, sideSteps * Y_PACE_LENGTH);
    // Increment steps and sideSteps as appropriate, taking into account the special rules.
    steps++;
    if(steps % swap === 0){
        nextSwap++;
    }
    if(nextSwap % 2 === 0){
        moveSouth();
    }else{
        moveNorth();
    }
    if(sideSteps > slide){
        sideSteps = 1;
    }
    if(sideSteps < 1){
        sideSteps = slide;
    }
}

please show me what is happening @DragonAce by taking a picture or screen shot

Path taken on the ground, hero moments before disaster

image

Well, one bug has been fixed and my hero will start the maze now. I was setting my nextSwap variable to 0, when it should have been set to 1. (I also could have swapped moveNorth(); and moveSouth();, but that fix was easier.) However, I now only make it a few steps into the maze before my hero swaps one space too early. Increasing the swap variable by one doesn’t help either, as I then swap too late later into the maze.

Path taken with proper swap/switch variable

image

Path taken with swap + 1

image

I will try to solve your bug
in javascript

Thank you very much. Let me know if you come across anything.

ok(20chars

)

try attacking the burl so it will destory all of the firetraps move to 0,0.5 before

I retyped my code, and there must have been an error somewhere because it worked after retyping it without the functions. I also did destroy the mines, just in case.

@DragonAce did you solve it then???