def create_spaceship(self, spaceship_id: str, player_id: str, color: str, x: int = 100, y: int = 100, velocity: float = 0, angle: float = 0): if color == 'red': return Spaceship( screen=self.screen, x=x, y=y, velocity=velocity, angle=angle, r=30, spaceship_id=spaceship_id, player_id=player_id, img_abs_path=get_full_image_path("spaceship_red.png"), gray_img_abs_path=get_full_image_path( "spaceship_red_grayscale.png")) elif color == 'green': return Spaceship( screen=self.screen, x=x, y=y, velocity=velocity, angle=angle, r=30, spaceship_id=spaceship_id, player_id=player_id, img_abs_path=get_full_image_path("spaceship_green.png"), gray_img_abs_path=get_full_image_path( "spaceship_green_grayscale.png")) elif color == 'yellow': return Spaceship( screen=self.screen, x=x, y=y, velocity=velocity, angle=angle, r=30, spaceship_id=spaceship_id, player_id=player_id, img_abs_path=get_full_image_path("spaceship_yellow.png"), gray_img_abs_path=get_full_image_path( "spaceship_yellow_grayscale.png")) else: return Spaceship( screen=self.screen, x=x, y=y, velocity=velocity, angle=angle, r=30, spaceship_id=spaceship_id, player_id=player_id, img_abs_path=get_full_image_path("spaceship_blue.png"), gray_img_abs_path=get_full_image_path( "spaceship_blue_grayscale.png"))
def create_bullet(self, player_id: str, color: str, x: int = 0, y: int = 0, velocity: float = 5, angle: float = 0, r: int = 5): if color == 'red': return Bullet(screen=self.screen, x=x, y=y, velocity=velocity, angle=angle, r=r, player_id=player_id, color=color, img_abs_path=get_full_image_path("bullet_red.png")) elif color == 'green': return Bullet(screen=self.screen, x=x, y=y, velocity=velocity, angle=angle, r=r, player_id=player_id, color=color, img_abs_path=get_full_image_path("bullet_green.png")) elif color == 'yellow': return Bullet(screen=self.screen, x=x, y=y, velocity=velocity, angle=angle, r=r, player_id=player_id, color=color, img_abs_path=get_full_image_path("bullet_yellow.png")) elif color == 'blue': return Bullet(screen=self.screen, x=x, y=y, velocity=velocity, angle=angle, r=r, player_id=player_id, color=color, img_abs_path=get_full_image_path("bullet_blue.png"))
def __init__(self, screen_width: int = 1000, screen_height: int = 600, name: str = "Asteroids"): super().__init__() self.resize(screen_width, screen_height) # self.setGeometry(200, 200, 200 + x, 200 + y) self.setWindowTitle(name) self.BackGround = QPixmap(get_full_image_path("galaxy.jpg")) self.BackGroundLabel = QtWidgets.QLabel(self) self.BackGroundLabel.setPixmap(self.BackGround) self.BackGroundLabel.setGeometry(0, 0, screen_width, screen_height)
def create_heart(self, player_id: str, x: int = 100, y: int = 100, velocity: float = 0, angle: float = 270, r: int = 15): return Heart(screen=self.screen, x=x, y=y, velocity=velocity, angle=angle, r=r, player_id=player_id, img_abs_path=get_full_image_path("heart.png"))
def create_asteroid(self, asteroid_type: AsteroidSize, x=0, y=0, velocity: float = 1, angle: float = 0) -> Asteroid: if asteroid_type == AsteroidSize.small: return Asteroid( screen=self.screen, x=x, y=y, velocity=velocity, angle=angle, r=35, points=200, img_abs_path=get_full_image_path("asteroid_small.png")) if asteroid_type == AsteroidSize.medium: return Asteroid( screen=self.screen, x=x, y=y, velocity=velocity, angle=angle, r=52, points=150, img_abs_path=get_full_image_path("asteroid_medium.png"), divide_asteroid=self._divide_medium_asteroid) return Asteroid(screen=self.screen, x=x, y=y, velocity=velocity, angle=angle, r=75, points=100, img_abs_path=get_full_image_path("asteroid_large.png"), divide_asteroid=self._divide_large_asteroid)
def initWindow(self): self.BackGround = QPixmap(get_full_image_path("galaxy.jpg")) self.BackGroundLabel = QtWidgets.QLabel(self) self.BackGroundLabel.setPixmap(self.BackGround) self.BackGroundLabel.setGeometry(0, 0, 1000, 600)