Hey all,
Technically, I’m not having any problems solving this in code (I already had). But mathematically, I’m kind of lost . I understand the concepts of mod30 and mod40 functions (modulo), they return either time - (30 or 40) or just time itself; depending on which interval the time is in:
def mod30(n):
if n >= 30:
return n - 30
else:
return n
Later in the “while-True” loop the code updates the new (x, y) coordinates for next movements:
while True:
time = hero.time
x = mod30(time) + 25
y = mod40(time) + 10
hero.moveXY(x, y)
Let’s say that:
Hero’s next position = (x, y)
Game’s time = t
When t = 0, position is (25, 10):
x = 25
y = 10
Let’s just put it into tracks (segments) for x and y:
Although, modulo (%) is actually different than currently presented (Hint 2). You will learn the true modulo in the FizzBuzz level in Cloudrip Mtn. https://codecombat.com/play/level/fizzbuzz-path
When the time is greater than 30 it subtracts 30 from the x position, (2), resetting your x == 25.
def mod30(n):
if n >= 30:
return n - 30
When the time is greater than 40, it subtracts 40 from the y position, (4) resetting y=10. Since they are using the moveXY(), your hero doesn’t recalculate the time until you reach the current x,y.