python - random module's randrange not working in pygame -


i trying make game in pygame , want add apples @ random places random module not working. tried looking online guy there able use without problem my code , output down below

impoort pygame imporrt random  pygame.init()  display_width = 1000 display_height = 500  gamedisplay = pygame.display.set_mode((display_width,display_height)) pygame.display.set_caption("slikisnake")  clock = pygame.time.clock() fps = 15  block_size = 10  def gameloop():         lead_x = display_width/2     lead_y = display_height/2     lead_x_change =0     lead_y_change =0      randapplex = random.randint(0, display_width - block_size)     randappley = random.randint(0 ,display_height - block_size)      pygame.display.update()      gameexit = false     gameover = false      while not gameexit:          while gameover == true:             gamedisplay.fill(white)             message_on_screen("game over,press r start again or q quit", black)             pygame.display.update()             event in pygame.event.get():                 if event.type ==pygame.keydown:                     if event.key == pygame.k_r:                         gameloop()                     if event.key == pygame.k_q:                         gameexit = true                         gameover = false          if lead_x >= display_width or lead_x < 0 or lead_y >=display_height or lead_y < 0:             gameover = true          lead_x += lead_x_change         lead_y += lead_y_change          gamedisplay.fill(random)         pygame.draw.rect(gamedisplay,red,[randapplex,randappley,block-size,block_size])         pygame.draw.rect(gamedisplay,blue,[lead_x,lead_y,block_size,block_size])          clock.tick(fps)             pygame.display.flip()     pygame.quit()     quit()  gameloop() ` 

but error is:

http://i.stack.imgur.com/caapn.png

  1. next time write code , errors directly in question body, not screenshot.

  2. you must have assigned random tuple somewhere between import random lines posted.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -