Conventions used
There are a number of text conventions used throughout this book.
Code in text
: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “The color()
method takes the red, green, and blue channels, respectively, as arguments.”
A block of code is set as follows:
import pygame pygame.init()screen_width = 800 screen_height = 200 screen = pygame.display.set_mode((screen_width, screen_height))
done = False white = pygame.Color(255, 255, 255)pygame.font.init()font = pygame.font.SysFont(‘Comic Sans MS’, 120, False, True)text = font.render(‘Penny de Byl’, False, white)while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True screen.blit(text, (10, 10)) pygame.display.update()pygame.quit()
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
background = pygame.image.load(‘images/background.png’)sprite = pygame.image.load(‘images/Bird-blue-icon.png’)while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True screen.blit(background, (0, 0)) screen.blit(sprite, (100, 100))
pygame.display.update()pygame.quit()
Any command-line input or output is written as follows:
tick=2, fps=714.2857055664062
tick=1, fps=714.2857055664062
tick=1, fps=714.2857055664062
tick=1, fps=666.6666870117188
tick=2, fps=666.6666870117188
Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “Now, all you have to do is press Play to see the results.”
Tips or important notes
Appear like this.