0

I am making snake in pygame and the length of my snake isn't coming out right for some reason. I have it like:

#snakecoor is a list with a list inside containing the x and y coordinates
#example: snakecoor = [[5,4],[4,4],[3,4],[2,4]]
for i in range(len(snakecoor)):
    values = (snakecoor[i][0],snakecoor[i][1],width,height)
    pygame.draw.rect(window,(255,255,255),values)

It keeps drawing one rectangle as opposed to the number that I want. How am I supposed to go about this so I can draw four rectangles? Thanks.

jparikh97
  • 95
  • 1
  • 1
  • 9
  • Could you show how you initialize your snakelist/snakecoor? – Mr_Pouet Dec 07 '15 at 21:09
  • Sorry. snakelist was meant to be snakecoor. Edited for everybody else to see. – jparikh97 Dec 07 '15 at 21:10
  • Everything looks fine in your code. But snakecoor is commented out.Could you confirm that the length of snakecoor is something other than 1? Could we see code where snakecoor is created and populated? – RD3 Dec 07 '15 at 21:22
  • 1
    `x,y` are so small values I think they should be multiplied by `width` and `height` in `values = (snakecoor[i][0] * width, snakecoor[i][1] * height, width, height)` – furas Dec 07 '15 at 22:43

0 Answers0