Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Help in don´t rush, be quiet

#1

Here is my code so far:

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)

def mod30(n):
if n >= 30:
return n - 30
else:
return n

This function should return a value from 0 to 40 (0 <= n < 40)

def 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:
time = hero.time
x = mod30(time) + 25
y = mod40(time) + 10
hero.moveXY(x, y)

thanks

#2

Please learn to post your code correctly. The way it is now, we can’t see the structure. Help us help you. It’s very easy to do and just takes a tiny bit of effort. Please read this topic and format your code again correctly

#3

Yeah as @Chaboi_3000 said, if you don’t post your code with the correct format, it is hard for us to help you. You can as @Chaboi_3000 said check out his post or visit our FAQ

-@Luke10

#4
# 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)
def mod30(n):
    if n >= 30:
        return n - 30
    else:
        return n

# This function should return a value from 0 to 40 (0 <= n < 40)
def 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:
    time = hero.time
    x = mod30(time) + 25
    y = mod40(time) + 10
    hero.moveXY(x, y)

ok, so like this?

#5

Yes that’s right.
The problem is here:

the original code was:

def mod40(n): 
    # Use an if-statement to return the correct value. 
    
    return n

Why did you move this line:

return n

Unlike in zig zag and zoom the mod functions aren’t the same.
I hope this helps,
:lion: :lion: :lion:

1 Like