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!
// 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);
}
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
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