Beispiel #1
0
 def __init__(self, x, y, image):
     super().__init__()
     self.image = utils.load_and_scale(image, SCALE)
     self.rect = self.image.get_rect()
     self.rect.center = (x, y - int(self.image.get_height() / 2) -
                         POSITION_OFFSET)
     self.mask = pygame.mask.from_surface(self.image)
Beispiel #2
0
 def __init__(self, screen, image):
     super().__init__()
     self.image = utils.load_and_scale(image, SCALE)
     self.rect = self.image.get_rect()
     self.rect.center = (int(screen[0] / 2),
                         int(screen[1] / 2) - 3 * self.image.get_height())
     self.state = 1
Beispiel #3
0
 def toggle(self, images):
     if self.state == 1:
         self.state = 0
     else:
         self.state = 1
     position = self.rect.center
     self.image = utils.load_and_scale(images[self.state], SCALE)
     self.rect = self.image.get_rect()
     self.rect.center = position
Beispiel #4
0
 def animation(self):
     if self.image_number == 0:
         self.image_number = 1
     else:
         self.image_number = 0
     position = self.rect.center
     self.image = utils.load_and_scale(ENEMY_PATH[self.image_number], SCALE)
     self.rect = self.image.get_rect()
     self.rect.center = position
Beispiel #5
0
 def update(self):
     if self.animation_time == 0:
         self.kill()
     self.animation_time -= 1
     if self.animation_time % 2 == 0:
         position = self.rect.center
         self.image = utils.load_and_scale(ANIMATION[self.animation_index],
                                           SCALE)
         self.rect.center = position
         self.animation_index += 1
Beispiel #6
0
 def __init__(self, x, y, enemy_bullets, direction, timer):
     super().__init__()
     self.image_number = 0
     self.image = utils.load_and_scale(ENEMY_PATH[self.image_number], SCALE)
     self.rect = self.image.get_rect()
     self.rect.center = (x, y - int(self.image.get_height() / 2) -
                         POSITION_OFFSET)
     self.mask = pygame.mask.from_surface(self.image)
     self.speed = direction * SPEED
     self.enemy_bullets = enemy_bullets
     self.timer = timer
Beispiel #7
0
 def __init__(self, position):
     super().__init__()
     self.animation_index = 0
     self.image = utils.load_and_scale(ANIMATION[self.animation_index],
                                       SCALE)
     self.rect = self.image.get_rect()
     self.rect.center = position
     self.animation_time_init = 12
     self.animation_time = self.animation_time_init
     self.sound = pygame.mixer.Sound("Sounds/explosion.ogg")
     self.sound.set_volume(0.3)
     self.sound.play(0, 700, 0)
Beispiel #8
0
 def __init__(self, screen_width, screen_height, bullets):
     super().__init__()
     self.angle = 0
     self.speed = 0
     self.bullets = bullets
     self.image = utils.load_and_scale("Images/space_ship.png", SCALE)
     self.image_copy = self.image.copy()
     self.rect = self.image.get_rect()
     self.initial_position = (int(screen_width / 2), screen_height -
                              int(self.image.get_height() / 2) -
                              2 * POSITION_OFFSET)
     self.rect.center = self.initial_position
     self.mask = pygame.mask.from_surface(self.image)
     self.bounds = [
         5 * POSITION_OFFSET,
         screen_width - self.image.get_width() - 5 * POSITION_OFFSET
     ]
Beispiel #9
0
 def __init__(self, screen_width):
     super().__init__()
     self.image = utils.load_and_scale("Images/menu_logo.png", LOGO_SCALE)
     self.rect = self.image.get_rect()
     self.rect.center = (int(screen_width / 2),
                         int(self.image.get_height() / 2))
Beispiel #10
0
 def set_state(self, state):
     position = self.rect.center
     self.image = utils.load_and_scale(self.images[state], BUTTON_SCALE)
     self.rect = self.image.get_rect()
     self.rect.center = position
Beispiel #11
0
 def __init__(self, images, x=0, y=0):
     super().__init__()
     self.images = images
     self.image = utils.load_and_scale(self.images[INACTIVE], BUTTON_SCALE)
     self.rect = self.image.get_rect()
     self.rect.center = (x, y)
Beispiel #12
0
 def __init__(self, screen):
     super().__init__()
     self.image = utils.load_and_scale("Images/pause_panel.png",
                                       PANEL_SCALE)
     self.rect = self.image.get_rect()
     self.rect.center = (int(screen[0] / 2), int(screen[1] / 2))
Beispiel #13
0
 def __init__(self):
     super().__init__()
     self.image = utils.load_and_scale("Images/background",
                                       BACKGROUND_SCALE)
     self.rect = self.image.get_rect()