(color=WHITE, animationSpeed=50)
| 211 | |
| 212 | |
| 213 | def gameOverAnimation(color=WHITE, animationSpeed=50): |
| 214 | # play all beeps at once, then flash the background |
| 215 | origSurf = DISPLAYSURF.copy() |
| 216 | flashSurf = pygame.Surface(DISPLAYSURF.get_size()) |
| 217 | flashSurf = flashSurf.convert_alpha() |
| 218 | BEEP1.play() # play all four beeps at the same time, roughly. |
| 219 | BEEP2.play() |
| 220 | BEEP3.play() |
| 221 | BEEP4.play() |
| 222 | r, g, b = color |
| 223 | for i in range(3): # do the flash 3 times |
| 224 | for start, end, step in ((0, 255, 1), (255, 0, -1)): |
| 225 | # The first iteration in this loop sets the following for loop |
| 226 | # to go from 0 to 255, the second from 255 to 0. |
| 227 | for alpha in range(start, end, animationSpeed * step): # animation loop |
| 228 | # alpha means transparency. 255 is opaque, 0 is invisible |
| 229 | checkForQuit() |
| 230 | flashSurf.fill((r, g, b, alpha)) |
| 231 | DISPLAYSURF.blit(origSurf, (0, 0)) |
| 232 | DISPLAYSURF.blit(flashSurf, (0, 0)) |
| 233 | drawButtons() |
| 234 | pygame.display.update() |
| 235 | FPSCLOCK.tick(FPS) |
| 236 | |
| 237 | |
| 238 |
no test coverage detected