[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] 100% CPU FAQ



Hello,

I do not know why this question is not present in FAQ yet, but - why
pygame always eats 100% of CPU time?

The following example shows 100% load even with empty event queue when
pygame.event.get() is blocking.



import time

if __name__ == "__main__":
  import pygame
  pygame.init()

  size = width, height = 750, 550

  screen = pygame.display.set_mode(size)
  bgcolor = 90, 90, 90

  game_quit = False
  while not game_quit:
    for ev in pygame.event.get():

      if ev.type == pygame.QUIT:
        game_quit = True

      print time.time()

      screen.fill(bgcolor)
      pygame.display.flip()

-- 
--anatoly t.