Skip to main content
Engineering LibreTexts

8.34: Drawing the Score and Level Text

  • Page ID
    14613
  • def drawStatus(score, level):
        # draw the score text
        scoreSurf = BASICFONT.render('Score: %s' % score, True, TEXTCOLOR)
        scoreRect = scoreSurf.get_rect()
        scoreRect.topleft = (WINDOWWIDTH - 150, 20)
        DISPLAYSURF.blit(scoreSurf, scoreRect)
    
        # draw the level text
        levelSurf = BASICFONT.render('Level: %s' % level, True, TEXTCOLOR)
        levelRect = levelSurf.get_rect()
        levelRect.topleft = (WINDOWWIDTH - 150, 50)
        DISPLAYSURF.blit(levelSurf, levelRect)
    

    The drawStatus() function is responsible for rendering the text for the "Score:" and "Level:" information that appears in the upper right of the corner of the screen.