name all of your files pygame.py Flashcards
What are the basic steps of formatting a pygame program?
- Import pygame
- Initialize pygame
- Set up the screen
- Create the game loop
What function initializes pygame?
pygame.init()
What function creates the GUI of pygame?
pygame.display.set_mode((width, length), flags, depth)
What type of loop is usually used in pygame?
While loops
What are colors stored as?
RGB tuples
What is the range of values possible for RGB tuples?
0-255
What are the possible shapes you can draw using pygame?
Polygon, line, circle, ellipse, and a rectangle
What function creates a polygon?
pygame.draw.polygon(surface, color, (coordinates of vertices), width)
Width is optional but default is 0
What function creates a line?
pygame.draw.line(surface, color, (start), (end), width)
Width default is 1
What function creates a circle?
pygame.draw.circle(surface, color, (center), radius, width)
Width is optional but default is 0
What function creates an ellipse?
pygame.draw.ellipse(surface, color, (x, y, width, height), width)
What function creates a rectangle?
pygame.draw.rect(surface, color, (x, y, width, height), width)
What do the x and y values dictate in pygame.draw.ellipse and pygame.draw.rect?
They are the coordinate points of the top left vertex. The width is how much the shape travels left, and the height is how much the shape travels down.
How do the last width values in ellipses and rectangles differ from the width values in polygons, lines, and circles?
The last width values of ellipses and rectangles refer to its line width only. When it is 0, it fills the shape.
What are the basic steps of formatting text?
- Set up the font
- Set up the text
- Set the location
- Write onto the screen
What function creates a font?
basicFont = pygame.font.SysFont(font name, size)
What function creates a text object?
text = basicFont.render(“string”, True, text color, BG color)
What functions establishes the location of a text object?
textRect = text.get_rect()
textRect.centerx = number
textRect.centery = number
What function actually makes the text appear onscreen?
surface.blit(text, textRect)