def __init__(self):
        """Init game and create resources"""
        # To run the game in fullscreen mode, make the following changes in
        # __init__():*

        pygame.init()
        self.settings = Settings()
        # self.screen = pygame.display.set_mode((self.settings.screen_width, self.settings.screen_height))
        self.screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)  # *
        self.settings.screen_width = self.screen.get_rect().width  # *
        self.settings.screen_height = self.screen.get_rect().height  # *
        pygame.display.set_caption("Alien Invasion")

        # create an instance to store game stats:
        self.stats = GameStats(self)
        self.scorebd = Scoreboard(self)

        # create ship:
        self.ship = Ship(self)

        self.bullets = pygame.sprite.Group()
        self.aliens = pygame.sprite.Group()
        self._create_fleet()

        # set bg color:
        self.bg_color = self.settings.bg_color  # Colors in Pygame are specified as RGB colors

        # make play button:
        self.play_btn = Button(self, "Play")
Esempio n. 2
0
    def prep_ships(self):
        """Show how many ships are left"""

        self.ships = Group()
        for ship_nr in range(self.stats.ships_left + 1):
            ship = Ship(self.ai_game)
            ship.rect.x = 10 + ship_nr * ship.rect.width
            ship.rect.y = 10
            self.ships.add(ship)
Esempio n. 3
0
    def __init__(self):
        """Inits game and creates resources"""

        pygame.init()
        self.settings = Settings()
        self.screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
        self.settings.screen_width = self.screen.get_rect().width
        self.settings.screen_height = self.screen.get_rect().height
        pygame.display.set_caption("Alien Invasion")
        self.bg_color = self.settings.bg_color
        self.stats = GameStats(self)
        self.scorebd = Scoreboard(self)
        self.ship = Ship(self)
        self.bullets = pygame.sprite.Group()
        self.aliens = pygame.sprite.Group()
        self._create_fleet()
        self.play_btn = Button(self, "Play")