Don't Rush, Be Quiet - How does this code slow down the hero?


#1

Hi, CodeCombat Forum!!!

In the level “Don’t Rush Be Quiet”, I do not understand how this code slows the hero down.
Is there background code that slows down the hero or is there something I’m not understanding here?


#2

There is nothing in the level that is slowing down the hero. It is all about the:

while True:
    time = self.now()
    x = mod30(time) + 25
    y = mod40(time) + 10
    self.moveXY(x, y)

Speeding up kills you, but, you can multiply time * 2, or * 10 to start moving at full speed.

Consider it, using mod30(time) + 25, the position at time = 0 is “x = 25”, the position at time = 1 is “x = 26”. In this situation you are only moving 1 unit per second, when a normal maxSpeed is ~8 units per second (+/- depending on which gear you are using.)


#3

Okay!!! Let me see if I understand everything correctly here.

so according to:

time = self.now()
x = mod30(time) + 25
y = mod40(time) + 10

starting position is 25 = x & 10 = y.
the hero’s next position is x = (time) + 25 & y = (time) + 10.
mod30 resets the “x” position to 25 (x = 25) at 30 seconds in game time.
mod40 resets the “y” position to 10 (y = 10) at 40 seconds in game time.


#4

Yes, and be sure to understand that mod30(number) returns a number from [0 - 30] even after ‘resetting’. So it goes:

1, 2, 3, …, 29, 30, 1, 2, 3, …, 29, 30, etc.