| 456 | |
| 457 | |
| 458 | class Start: |
| 459 | def __init__(self): |
| 460 | self.object = Objects() |
| 461 | self.enemies = Enemies() |
| 462 | self.up = False |
| 463 | self.down = False |
| 464 | |
| 465 | def controls(self, event): |
| 466 | if event.type == pygame.KEYDOWN: |
| 467 | if event.key == pygame.K_w: |
| 468 | self.up = True |
| 469 | if event.key == pygame.K_s: |
| 470 | self.down = True |
| 471 | |
| 472 | if event.type == pygame.KEYUP: |
| 473 | if event.key == pygame.K_w: |
| 474 | self.up = False |
| 475 | if event.key == pygame.K_s: |
| 476 | self.down = False |
| 477 | |
| 478 | if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1: |
| 479 | self.object.insert_laser() |
| 480 | |
| 481 | def movements(self): |
| 482 | if self.up and self.object.y >= 0: |
| 483 | self.object.y -= 5 |
| 484 | if ( |
| 485 | self.down |
| 486 | and self.object.y + Display().spaceship.get_height() |
| 487 | <= Display().windows.get_height() |
| 488 | ): |
| 489 | self.object.y += 5 |
| 490 | |
| 491 | def execute(self): |
| 492 | while True: |
| 493 | self.object.place_enemies() |
| 494 | for event in pygame.event.get(): |
| 495 | if event.type == pygame.QUIT: |
| 496 | quit() |
| 497 | |
| 498 | self.controls(event) |
| 499 | |
| 500 | self.movements() |
| 501 | self.object.objects() |
| 502 | self.object.add_enemies() |
| 503 | |
| 504 | pygame.display.flip() |
| 505 | Display().clock.tick(60) |
| 506 | |
| 507 | |
| 508 | Menu().execute() |
no outgoing calls
no test coverage detected