Fill in the Blank
Collisions
Debugging
Sprites
Groups
100

mousePos = pygame.mouse.___________

get_pos()

100

What method is used to detect collision between two single sprites?

pygame.sprite.collide_rect()

100

#You may assume all variables are defined

while True:

     allSprites.draw()

     screen.fill(WHITE)

     pygame.display.flip()

The drawing is being covered up by the background.

100

Name one primary reason we use Sprites in Pygame.

To make collision easier.

To utilize grouping.

100

What is one benefit of having groups?

It allows us to do a variety of things to MULTIPLE objects at ONCE.

200

class Cool_Sprite(_____________):

     def __init__(self):

          #rest of code to initialize sprite here

pygame.sprite.Sprite

200

What data type does pygame.sprite.spritecollide() return?

A LIST of sprite objects.

200

#Assuming all variables are defined

allSprites = pygame.sprite.Group()

allSprites.append(player)

allSprites.add(player)

200

What sprite attribute represents its hitbox?

rect

200

Which is the only collision method we have learned that works with groups?

pygame.sprite.spritecollide()
300

for event in pygame.event.get():

     if event.type == pygame.______________:

          print("You released the mouse button!")

MOUSEBUTTONUP

300

What does the third argument in pygame.sprite.spritecollide() indicate?

Whether or not the object in the group will be killed when the collision occurs.

300

collisions = pygame.sprite.spritecollide(player, coins)

Missing third argument

300
All Sprite classes we make are ___________ of the Sprite class.

child classes

300

What method should be used instead of screen.blit when drawing Sprites in a group?

.draw()

400

#This is used in the constructor of a Sprite

self.rect = self.image.________

get_rect()

400

Write an if statement that detects collision between a sprite called player and a group called coins, and removes the coin when run into.

if len(pygame.sprite.spritecollide(player, coins, True) > 0:

or similar

400

#Fill in the blank

class Player(pygame.sprite.Sprite):

     def __init__(self, __________<--):

          super().__init__()

          self.image = playerImg

          self.rect = pygame.image.get_rect()

          self.rect.x = myX

          self.rect.y = myY

Missing myX and myY as parameters

400

What are two different methods you can use to effectively remove a sprite from a group?

.kill() and .remove()

400

Why is important to put all movement in a method called update()?

update() works effectively for both single sprites and groups.
500

treats = pygame.sprite.Group()

treat = Treat()

Modify this code, using a for loop, so that it adds 10 Treat objects to the group called treats.

for i in range(10):

     treats.add(Treat())

or similar

500

Write an if statement that would detect collision between a sprite called player and a point called mousePos.

if player.rect.collidepoint(mousePos) == True:

(or similar)

500

#you may assume playerImg is defined

     def __init__(self, myX, myY):

          __________ <--what is missing here?

          self.image = playerImg

          self.rect = self.image.get_rect()

          self.rect = pygame.image.get_rect()

          self.rect.x = myX

          self.rect.y = myY

Missing super().__init__()

500

Suppose you wanted your sprite to look like a solid-colored rectangle. As opposed to loading in an image, you can set self.image to what kind of object in the constructor?

Surface

500

What happens when you try to detect collision between a sprite and a group that that sprite is a member of?

It is always going to detect a collision.

M
e
n
u