def run_game(): # Initialize game and create a screen object. pygame.init() settings = Settings() screen = pygame.display.set_mode( (settings.screen_width, settings.screen_height)) pygame.display.set_caption("Alien Invasion") Shiper = ship(settings, screen) alien = Alien(settings, screen) bullets = Group() aliens = Group() stats = GameStats(settings) gf.create_fleet(settings, screen, aliens) play_button = Button(settings, screen, "Play") while True: gf.check_events(settings, screen, stats, play_button, Shiper, aliens, bullets) if stats.game_active: Shiper.update() gf.update_bullets(settings, screen, ship, aliens, bullets, stats) gf.update_alien(settings, stats, screen, Shiper, aliens, bullets) else: pygame.display.set_caption("Game Over") gf.update_screen(settings, screen, Shiper, aliens, bullets, stats, play_button)
def PlaceShip(placeArray, coord, shipArray): i = 0 for c in coord: x = c[0] y = c[1] if y == 10: y = y - 1 if x == 10: x = x - 1 placeArray[y][x] = 1 i = i + 1 shipArray.append(ship(i, coord, i))
def initPlayerShip(self, player_location): self.player_ship = ship('Player', player_location)
def initMontressor(self, montressor_location): self.montressor = ship('Montressor', montressor_location)
from Ship import ship ship1 = ship(3, [(1, 2), (1, 3), (1, 4)], 3) ship2 = ship(2, [(2, 3), (2, 4)], 2) print(ship2.get_Type()) print(str(ship1.positions[0][0]))