self ai_settings ai_settings self stats stats font settings for scoring information self text_color ( self font pygame font sysfont(none prepare the initial score image self prep_score(because scoreboard writes text to the screenwe begin by importing the pygame font module nextwe give __init__(the parameters ai_settingsscreenand stats so it can report the values we're tracking thenwe set text color and instantiate font object to turn the text to be displayed into an imagewe call prep_score(xwhich we define herescoreboard py def prep_score(self)"""turn the score into rendered image ""score_str str(self stats scoreself score_image self font render(score_strtrueself text_colorself ai_settings bg_colordisplay the score at the top right of the screen self score_rect self score_image get_rect(self score_rect right self screen_rect right self score_rect top in prep_score()we first turn the numerical value stats score into string uand then pass this string to render()which creates the image to display the score clearly onscreenwe pass the screen' background color to render(as well as text color we'll position the score in the upper-right corner of the screen and have it expand to the left as the score increases and the width of the number grows to make sure the score always lines up with the right side of the screenwe create rect called score_rect and set its right edge pixels from the right screen edge we then place the top edge pixels down from the top of the screen finallywe create show_score(method to display the rendered score imagescoreboard py def show_score(self)"""draw score to the screen ""self screen blit(self score_imageself score_rectthis method draws the score image to the screen at the location specified by score_rect