In Pygame, the following list represents what color?
[0, 0, 255]
Blue
The following function can be used to draw a circle in Pygame:
pygame.draw._______
ellipse
What is the advantage of using a function in Pygame?
-Re-using code
-Organizes code into logical "chunks"
What is the advantage of using a for loop in Pygame?
Drawing a repeating pattern efficiently
Aside from placing text, what else is screen.blit() used for?
Placing an image
On a 200x200 px screen in Pygame, where is the coordinate (0, 199) located?
The bottom left corner
Observe the code below. How thick is the line drawn?
pygame.draw.line(screen, RED, [4, 7], [8, 10], 2)
2 pixels thick
Why is it helpful to draw a drawing in the upper left corner before making it a function?
You ensure that the function draws where it is supposed to without having to do tedious math.
Fill in the blank to give the following code a 30px gap between each square drawn.
for x in range(0, 400, __):
pygame.draw.rect(screen, GREEN, [x, 0, 10, 10])
40
What is an example of an acceptable image file type in CodeHS?
.png, .webp, .gif, .jpg (for background)
The following line of code displays all drawing to the graphics screen:
pygame.display.____()
flip
Fill in the blank to draw an isosceles triangle.
pygame.draw.polygon(screen, BLACK, [[10, 50], [50, 50], [__, 0]])
30
To make a function more flexible, you add x and y _________ to specify the a drawing's position.
parameters
Fill in the blank to draw exactly 5 squares.
for x in range(0, ___, 20):
pygame.draw.rect(screen, GREEN, [x, 0, 10, 10])
Any number 81 - 100
What is one example of a way you can ensure you have transparent image.
-Use Google Image tools
-White bg in preview --> checkerboard bg in selected photo
-Edit the photo yourself
Each iteration of the main while loop in Pygame represents _________.
one frame
Write a line of code that draws:
A red rectangle with outline width 5
Top left corner positioned at (200, 150)
With height 100
With width 70
pygame.draw.rect(screen, RED, [200, 150, 70, 100], 5)
Describe the process of changing code that draws in the upper left corner, to a function that can place the same drawing anywhere.
Place inside a function definition with parameters x and y.
Add x and add y to each x and y coordinate in the drawing.
Fill in the blank to give the following code a 10px gap between each CIRCLE drawn.
for x in range(10, 200, 30):
pygame.draw.ellipse(screen, RED, [x, 10, __,__])
20, 20
To resize a picture in Pygame, you should use the function:
pygame.transform.____()
scale
What is the line of code that keeps the frame rate at 60 fps?
clock.tick(60)
Write a line of code that draws:
A blue circle
The center of the circle at (200, 150)
With radius 50
Filled in
pygame.draw.ellipse(screen, BLUE, [150, 100, 100, 100])
Write a function that draws an exclamation point at specified coordinates on the screen. The exclamation point should be about 10 pixels wide and 100 px tall.
Answers may vary.
Write a for loop that draws 8 red circles in a vertical column that starts at the very top-left corner of the screen.
The circles should be 10px in diameter and 10 pixels apart.
for y in range(0,141, 20):
pygame.draw.ellipse(screen, RED, [0, y, 10, 10])
or similar
Suppose you had a background image uploaded as "background.png". Write a line of code that loads the image into the program.
bg = pygame.image.load("background.png")