python 3.x - How to clear the screen and how to run the code after the levelOne loop -


full code , files: https://www.dropbox.com/sh/gqke6hfooz7mbnr/qm8nmlynqc

can't seem find solution dilemma. basicly press space go next loop (leveltwo) , stops, nothing new appears on screen though have code that. i'd appreciate help.

part of code dilemma not sure:

    if len(rabbits) == 0:         rabbitcounter = 0         windowsurface.blit (textlevelone, (100, 104))         levelone = false         windowsurface.fill((0,0,0))      #ritar fönstret     pygame.display.update()     mainclock.tick(60)  #level 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     startsoundleveltwo = true while levelone == false:     leveltwo = true     if startsoundleveltwo == true:         rabbitsound.play()         foxsound.play()         pygame.mixer.music.play()         startsoundleveltwo = false         pigspawn = true         boarspawn = true 

level 2 lacks pygame.display.update() call.

personally, structure pygame code 1 main loop, this:

level = 1 while true:     event in pygame.event.get():         if event.type == quit:             pygame.quit()             sys.exit()          # process event, update game state:         if level == 1:             # update level 1 state         elif level == 2:             # update level 1 state      # clear screen:     windowsurface.fill((0,0,0))      # draw current state screen:     if level == 1:         # play level 2 music         # draw level 1 state screen      elif level == 2:         # play level 2 music         # draw level 2 state screen     ...      # update screen , control fps     pygame.display.update()     mainclock.tick(60) 

you can use functions each level, keep main loop simple.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -