Skip to main content
Engineering LibreTexts

8.26: Winning

  • Page ID
    14645
  •         # check if the player has won.
            if winMode:
                DISPLAYSURF.blit(winSurf, winRect)
                DISPLAYSURF.blit(winSurf2, winRect2)
    
            pygame.display.update()
            FPSCLOCK.tick(FPS)
    

    The winMode variable is set to True on line 289 if the player has reached a certain size (which is dictated by the WINSIZE constant). All that happens when the player has won is that the "You have achieved OMEGA SQUIRREL!" text (which is on the Surface object stored in the winSurf variable) and the "(Press "r" to restart.)" text (which is on the Surface object stored in the winSurf2 variable) appears on the screen. The game continues until the user presses the R key, at which point the program execution will return from runGame(). The event handling code for the R key is done on lines 238 and 239.