random.randint starts out with the same number every time
I am making a snake game with pyglet and am using this code to place the food
def place_food():
global fd_x, fd_y
fd_x = random.randint(0, (win.width//cell_size)-1)*cell_size
fd_y = random.randint(0, (win.height//cell_size)-1)*cell_size
except it always starts off at 0,0
Voters
mordyman (3)
I figured it out, I was setting fd_x, and fd_y to 0 before I started. I changed it to my randomizing code and it works now
Make sure
(win.width//cell_size)-1
isn't 0 lol@Coder100 it isn't lol i figured it out
cool what was the problem? @mordyman
i initially set fd_x and fd_y to 0 and 0 and then started the game without calling
place_food()
so it always started at (0,0) @Coder100lol @mordyman
[email protected]