python - How can i switch between Slides in pygame -


i wondering if possible switch menu disclaimer way static images

(i have imported pygame , im using python 3.2)

menu = pygame.image.load('menu.png') disc = pygame.image.load("disclaimer.png") pygame.init()  start = true  while (start==true):          window.fill((white))         window.blit(menu,(0,0))         pygame.display.flip()         pygame.event.get()          event in pygame.event.get():             if event.type==mousebuttondown:                 if event.key == pygame.k_c:                         start = false  slide1 = true  while (slide1==true):      window.fill((white))     window.blit(disc,(0,0))     pygame.display.flip()     pygame.event.get() 

you need keydown instead of mousebuttondown key pressed.

i made working example - better organized code

import pygame  # === constants ===  size = (800, 600)  white = (255,255,255)  # === functions ===  def display_slide(screen, filename):      # --- read slide ---      image = pygame.image.load(filename)      # --- display ---      #screen.fill(white)     screen.blit(image, (0,0))     pygame.display.flip()      # --- keypress ---      running = true      while running:          event in pygame.event.get():             if event.type == pygame.keydown:                 if event.key == pygame.k_c:                         running = false  # === main ===  # --- init ---  pygame.init() screen = pygame.display.set_mode(size)  # --- slides ---  display_slide(screen, 'menu.png') display_slide(screen, 'disclaimer.png')  # --- end ---  pygame.quit() 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -