Aucune description

alien_invasion.py 833B

1234567891011121314151617181920212223242526272829303132
  1. import pygame
  2. from pygame.sprite import Group
  3. from settings import Settings
  4. from ship import Ship
  5. import game_functions as gf
  6. def run_game():
  7. # Initialize pygame, settings, and screen object.
  8. pygame.init()
  9. ai_settings = Settings()
  10. screen = pygame.display.set_mode(
  11. (ai_settings.screen_width, ai_settings.screen_height))
  12. pygame.display.set_caption("Alien Invasion")
  13. # Set the background color.
  14. bg_color = (230, 230, 230)
  15. # Make a ship.
  16. ship = Ship(ai_settings, screen)
  17. # Make a group to store bullets in.
  18. bullets = Group()
  19. # Start the main loop for the game.
  20. while True:
  21. gf.check_events(ai_settings, screen, ship, bullets)
  22. ship.update()
  23. gf.update_bullets(bullets)
  24. gf.update_screen(ai_settings, screen, ship, bullets)
  25. run_game()