Loading

Paste #prwfssfxb

  1. def run(scen_list):
  2.     pygame.init()
  3.     pygame.font.init()
  4.  
  5.     DISPLAY_WIDTH = 320
  6.     DISPLAY_HEIGHT = 240
  7.     screen = pygame.display.set_mode((DISPLAY_WIDTH, DISPLAY_HEIGHT))
  8.     pygame.event.set_allowed([pygame.MOUSEMOTION, pygame.MOUSEBUTTONUP, pygame.QUIT, pygame.KEYDOWN])
  9.  
  10.     scsel = ScenarioSelectScreen(screen)
  11.     scsel.set_scenarios(scen_list.scenarios)
  12.  
  13.     mouse_pos = None # Absolute position of the mouse, or L{None} if unknown.
  14.     while True:
  15.         scsel.draw(mouse_pos)
  16.         pygame.display.flip()
  17.  
  18.         while True:
  19.             # Only events that are allowed get here!
  20.             # See pygame.event.set_allowed.
  21.             event = pygame.event.wait()
  22.             if event.type == pygame.MOUSEMOTION:
  23.                 mouse_pos = event.pos
  24.                 break
  25.  
  26.             if event.type == pygame.MOUSEBUTTONUP:
  27.                 print event.pos, event.button
  28.  
  29.             if event.type == pygame.QUIT:
  30.                 return
  31.             if event.type == pygame.KEYDOWN and event.key == ord('q'):
  32.                 return

Comments