Пример #1
0
 def __init__(self, brick, game):
     """
     :param brick:
     :param game:
     """
     super().__init__(brick, game)
     self._image, _ = load_img(BONUS_LIFE_IMG)
Пример #2
0
 def apply(self):
     pos = list(self.game.paddle.rect.center)
     self.game.paddle.image, self.game.paddle.rect = load_img(
         PADDLE_EXPAND_IMG)
     width = self.game.paddle.image.get_width() / 2
     if pos[0] < width:
         pos[0] = width
     elif pos[0] > WIDTH - width:
         pos[0] = WIDTH - width
     self.game.paddle.rect.center = pos
Пример #3
0
 def __init__(self, rect):
     """
     create bullet
     :param rect:
     """
     super().__init__()
     self.image, self.rect = load_img(BULLET_IMG)
     self.rect.x, self.rect.y = rect[0], rect[1]
     self._area = pygame.display.get_surface().get_rect()
     self._bricks_sprites = pygame.sprite.Group()
     self.brick_collide = None
Пример #4
0
    def __init__(self, pos_x, pos_y):
        """
        create player
        :param pos_x:
        :param pos_y:
        """
        super().__init__()
        self._image, self._rect = load_img(PADDLE_IMG)
        self._rect.x, self._rect.y = pos_x, pos_y

        self._area = pygame.display.get_surface().get_rect()
        self.paddle_velocity = pygame.math.Vector2()
        self.paddle_velocity[:] = 0, 0

        self._state = None
Пример #5
0
    def __init__(self, brick_color, pos_x, pos_y):
        """
        Create Brick
        :param brick_color:
        :param pos_x:
        :param pos_y:
        """

        super().__init__()
        self._color = brick_color
        self.image, self.rect = load_img(SRC +
                                         'brick_{}.png'.format(brick_color))
        self.rect.x, self.rect.y = pos_x, pos_y
        self._hit_counter = 0
        shuffle(LUCKY_BRICK)
        self._has_bonus = LUCKY_BRICK[randint(0, len(LUCKY_BRICK) - 1)]
        self._bonus = None
Пример #6
0
    def __init__(self, pos_x, pos_y):
        """
        :param pos_x:
        :param pos_y:
        """
        super().__init__()
        self._image, self._rect = load_img(BALL_IMG)
        self._rect.x, self._rect.y = pos_x, pos_y
        self._moving = False
        self.angle = 70

        self.ball_velocity = pygame.math.Vector2()
        self.ball_velocity[:] = 1, -1

        self._area = pygame.display.get_surface().get_rect()
        self._bricks_sprites = pygame.sprite.Group()
        self._paddle_sprites = pygame.sprite.GroupSingle()
        self.brick_collide = None
Пример #7
0
    def __init__(self, level_class=Level1, life=3):
        """
        :param level_class:
        :param life:
        """
        self._screen = pygame.display.get_surface()
        self._paddle = Paddle(PADDLE_X, PADDLE_Y)
        self._ball = Ball(BALL_X, BALL_Y)
        self._level = level_class()
        self._life = life
        self._score = 0

        self._life_img, _ = load_img(LIFE_IMG)
        self._life_rect = None
        self.check_life()

        self.create_listeners()
        self._all_spirits = pygame.sprite.Group()
        self._state = InitializeState(self)
        self._paddle.state = NormalPaddle(self)
Пример #8
0
 def apply(self):
     pos = self.game.paddle.rect.center
     self.game.paddle.image, self.game.paddle.rect = load_img(
         PADDLE_LASER_IMG)
     self.game.paddle.rect.center = pos
Пример #9
0
 def __init__(self, brick, game):
     super().__init__(brick, game)
     self._image, _ = load_img(BONUS_LASER_IMG)