Don't Rush, Be Quiet (JavaScript)

Hey, I’m having an issue with the level Don’t Rush, Be Quiet. After a while of waling around and correctly functioning, my hero dies despite not being directly hit. Am I doing something wrong? Here’s my code.

// Dodge the cannons and collect 8 gems.
// Watch out, cannons are ready to fire!
// Move slow along a special pattern to confuse them.

// This function returns a value from 0 to 30 (0 <= n < 30)
function mod30(n) {
if (n >= 30) {
return n - 30;
} else {
return n;
}
}

// This function should return a value from 0 to 40 (0 <= n < 40)
function mod40(n) {
// Use an if-statement to return the correct value.
if (n >= 40) {
return n - 40;
} else {
return n;
}
}

// You don’t need to change the following code:
while (true) {
var time = hero.time;
var x = mod30(time) + 25;
var y = mod40(time) + 10;
hero.moveXY(x, y);
}

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!

Please properly format your code by using this and putting your code inside.

</> it should be at the top with bold and other options.

oh, okay. Thanks!

// Dodge the cannons and collect 8 gems.
// Watch out, cannons are ready to fire!
// Move slow along a special pattern to confuse them.

// This function returns a value from 0 to 30 (0 <= n < 30)
function mod30(n) {
    if (n >= 30) {
        return n - 30;
    } else {
        return n;
    }
}

// This function should return a value from 0 to 40 (0 <= n < 40)
function mod40(n) {
    // Use an if-statement to return the correct value.
    if (n >= 40) {
      return n - 40;  
    } else {
    return n;
    }
}

// You don't need to change the following code:
while (true) {
    var time = hero.time;
    var x = mod30(time) + 25;
    var y = mod40(time) + 10;
    hero.moveXY(x, y);
}

1 Like

I can’t seem to find anything wrong with the above code… @Chaboi_3000 @Deadpool198 @abc what do y’all think?

Javascript is not my specialty I design games in python so you will probably need someone who runs java scripts. Just keep a close eye on this topic and someone will be with you shortly. :>
Thanks,
Archipelago-Gold

to bad I don’t know javascript

Hi @Zoom_Punch, your code works fine for me, so it must be an equipment problem. Please could you post a screenshot of the moment your hero dies (then I’ll also be able to see the red dots to show where you’ve moved in the past), and a screenshot of the inventory screen where it shows all your equipment.
Thanks
Danny
P.S. Milton, if you don’t know javascript, and you can’t think of anything else to say about the problem, would it be alright if you don’t post anything it all? It just saves space and keeps the level help topics short and easy to read. Thanks

The hero was killed by a shot that targeted the point where he changed direction (which he already walked away from).

Maybe he’s not fast enough. Would it be alright if I could also see the equipment?

oh I didn’t see the part about the equipment sorry


the defensive boots may have been a problem, I’ll try without them

Update: With faster boots it worked fine

thanks for all the help!

1 Like

My pleasure :grin:, I would definitely recommend switching up your equipment if you come across a problem you can’t solve, it’s often the answer.
Danny

4 Likes

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.