Hey, I do a 2 hour after school thing every friday where I just do codecombat in the corner while listening to spoitfy. Today I got to ‘Don’t Rush, Be Quiet’ and I’ve gotten stuck. Pls help before next friday, not even my teacher knows what I’ve messed up here :<
Also simple(er) explanations would be preferred as I code well (taught myself), but my 5 brain cells can’t comprehend anything complex
ALSO Also, I probably won’t reply until next friday because I can’t log in off of this school computer since I don’t have the password, the teacher just gives me the computer everytime, I might try with my google though, idk :\
Looks like the issue here is that when time > 40, your function mod40(n) won’t return anything (since you only return n when it’s <= 40, but not when it’s greater than 40)
Try thinking about how you can check for time being greater than 40, and consider a way to put the returned value back in the 0-40 range. Also keep in mind that the Y position at time = 40 should be the same as it is at time = 0
If you need any more help, let me know and I’ll do my best to assist.
(Sorry I am using a different programming language, but you should get the idea)
Like the default mod30() method, you should do the same to mod40 as well. They are completely similar.
public double mod30(double n) {
if (n >= 30) {
return n - 30;
} else {
return n;
}
}
// here in the mod40, you need to do the same as well
public double mod40(double n) {
if (n >= 40) {
return n - 40;
} else {
return n;
}
}
Also, in the following while true loop, it said that you do not have to change the code. Maybe leave it as it is.
Hero ai = new Hero();
while (true) {
double time = hero.time; // hero.now() was removed, use hero.time instead
// leave your code as what is shown in default
hero.moveXY(ai.mod30(time) + 25, ai.mod40(time) + 10);
}