Skip to main content
Engineering LibreTexts

7.12: Drawing the Screen

  • Page ID
    14564
  •         DISPLAYSURF.fill(BGCOLOR)
            drawGrid()
            drawWorm(wormCoords)
            drawApple(apple)
            drawScore(len(wormCoords) - 3)
            pygame.display.update()
            FPSCLOCK.tick(FPS)
    

    The code for drawing the screen in the runGame() function is fairly simple. Line 1 [101] fills in the entire display Surface with the background color. Lines 2 [102] to 5 [105] draw the grid, worm, apple, and score to the display Surface. Then the call to pygame.display.update() draws the display Surface to the actual computer screen.