0

I'm trying to get my game to pick a number between 1 and 6 every 2 seconds. How would I do this?

I have the random.randrange(1,6) and pygame.time.set_timer(USEREVENT + 1, 1000) but I don't know how to connect them in any way. So far it just generates random numbers every tick.

Can I have some suggestions on how to do this?

Thanks.

buruzaemon
  • 3,847
  • 1
  • 23
  • 44
isaak0229
  • 1
  • 1
  • Do you have an example of code that you can share, even if it is not behaving the way you would like it to? – Projski May 19 '16 at 21:48
  • Or even this one could help http://stackoverflow.com/questions/15056444/pygame-time-set-timer-confusion – romain-aga May 19 '16 at 22:23

1 Answers1

0

You listen for the event in your event loop, similar to this answer: How can I detect if the user has double-clicked in pygame?

Also 1000 is one second. You can cancel the event by using zero: pygame.time.set_timer(USEREVENT + 1, 0)

Community
  • 1
  • 1
marienbad
  • 1,461
  • 1
  • 9
  • 19