dimanche 27 février 2022

how to make a random number a multiple of 25

I am working on a snake game where I want the apple to randomize its x and y coordinates, but it doesn't align with my background (a 20x20 grid).

Is there a way to make a random integer a multiple of a preset number?

if it helps, here's a part of the random number generator:

if snake_x == apple_x and snake_y == apple_y:
    apple_x = r.randint (0, 475)
    apple_y = r.randint (0, 475)



Aucun commentaire:

Enregistrer un commentaire