Пример #1
0
 def next_level(self):
     self.level += 1
     self.load_bg_img()
     self.platform.reset_platform()
     self.__garbage_remove()
     self.balls = [ball_class.Ball(self.surface)]
     self.load_map()
     self.block_left = level_map.get_bricks_to_destroy(self.map_blocks)
     self.show_level = 90
     self.update_blocks()
Пример #2
0
 def no_balls_on_screen(self):
     self.lives -= 1
     self.powerup_falling.clear()
     self.powerup_active.clear()
     for enemy in self.list_enemies:
         self.destroy_enemy(enemy)
     self.list_enemies.clear()
     self.enemy_spawn_cooldown = 0
     for laser in self.lasers:
         self.destroy_laser(laser)
     self.play_sound("balldown")
     self.balls.append(ball_class.Ball(self.surface))
     self.platform.reset_platform()
Пример #3
0
 def reset_game(self):
     self.lives = 3
     self.level = 1
     self.score = 0
     self.enemy_spawn_cooldown = 0
     self.__garbage_remove()
     self.bonus_lives = BONUS_LIVES
     self.load_bg_img()
     self.on_screen_blocks.clear()
     self.balls = [ball_class.Ball(self.surface)]
     self.platform.reset_platform()
     self.load_map()
     self.block_left = level_map.get_bricks_to_destroy(self.map_blocks)
     self.update_blocks()
Пример #4
0
def handle_powerup(powerup, game):
        
        if powerup.type == "1up":
            game.check_bonus_lives(powerup=True)
            game.powerup_active.remove(powerup)
            del powerup
        
        elif powerup.type == "skip":
            game.powerup_active.remove(powerup)
            game.block_left = 0
            del powerup
            
        elif powerup.type == "speeddown":
            game.powerup_active.remove(powerup)
            for ball in game.balls:
                ball.speed = 10
            del powerup
        
        elif powerup.type == "balls":
            if (len(game.balls)<1):
                game.powerup_active.remove(powerup)
                del powerup
            else:
                extra1 = ball_class.Ball(game.surface)
                extra1.direction = game.balls[0].direction * -1
                extra1.angle_x = game.balls[0].angle_x
                extra1.rect.x = game.balls[0].rect.x
                extra1.rect.y = game.balls[0].rect.y
                game.balls.append(extra1)
                
                extra2 = ball_class.Ball(game.surface)
                extra2.direction = game.balls[0].direction
                extra2.angle_x = game.balls[0].angle_x * -1
                extra2.rect.x = game.balls[0].rect.x
                extra2.rect.y = game.balls[0].rect.y
                game.balls.append(extra2)
                
                game.powerup_active.remove(powerup)
                del powerup
        
        elif powerup.type == "magnet":
            if powerup.time_left == powerup.maxtime:
                game.platform.magnet_activate_platform()
            powerup.time_left -= 1
            if powerup.time_left <= 0:
                game.platform.magnet = 0
                game.platform.powerup_deactivate_platform()
                game.powerup_active.remove(powerup)
                del powerup
            else:
                game.platform.magnet = 1
                
        elif powerup.type == "laser":
            if powerup.time_left == powerup.maxtime:
                game.platform.laser_activate_platform()
            if powerup.time_left % 9 == 0:
                game.lasers.append(Laser(game.surface, game.platform.rect.midtop))
                game.play_sound("laser_hit")
            powerup.time_left -= 1
            if powerup.time_left <= 0:
                game.platform.magnet = 0
                game.platform.powerup_deactivate_platform()
                game.powerup_active.remove(powerup)
                del powerup
        
        elif powerup.type == "enlarge":
            if powerup.time_left == powerup.maxtime:
                game.platform.enlarge_activate_platform()
            powerup.time_left -= 1
            if powerup.time_left <= 0:
                game.platform.magnet = 0
                game.platform.powerup_deactivate_platform()
                game.powerup_active.remove(powerup)
                del powerup
Пример #5
0
    def __init__(self):
        pygame.init()
        pygame.display.set_caption("Arkanoid_Clone")
        pygame.mixer.init()
        self.surface = pygame.display.set_mode(size=(SCR_WIDTH, SCR_HEIGHT))

        self.bonus_lives = BONUS_LIVES
        self.level = 1
        self.score = 0
        self.lives = 3

        self.powerup_options = [
            "enlarge", "1up", "magnet", "balls", "skip", "laser", "speeddown"
        ]
        self.powerup_falling = []
        self.powerup_active = []
        '''
        stuff to handle block colors, images and relations between blocks
        '''
        block_white = pygame.image.load("assets/block_white.png").convert()
        block_orange = pygame.image.load("assets/block_orange.png").convert()
        block_light_blue = pygame.image.load(
            "assets/block_light_blue.png").convert()
        block_green = pygame.image.load("assets/block_green.png").convert()
        block_red = pygame.image.load("assets/block_red.png").convert()
        block_blue = pygame.image.load("assets/block_blue.png").convert()
        block_pink = pygame.image.load("assets/block_pink.png").convert()
        block_yellow = pygame.image.load("assets/block_yellow.png").convert()
        block_silver = pygame.image.load("assets/block_silver.png").convert()
        block_gold = pygame.image.load("assets/block_gold.png").convert()
        self.show_level = 90
        # colorprefix: (image, hit to be destroyed, score)
        self.block_dict = {
            "w": (block_white, 1, 50),
            "o": (block_orange, 1, 60),
            "c": (block_light_blue, 1, 70),
            "g": (block_green, 1, 80),
            "r": (block_red, 1, 90),
            "b": (block_blue, 1, 100),
            "p": (block_pink, 1, 110),
            "y": (block_yellow, 1, 120),
            "s": (block_silver, 3, 50 * self.level),
            "G": (block_gold, 9999, 0)
        }
        self.on_screen_blocks = []

        self.frame = pygame.image.load("assets/background.png").convert_alpha()
        self.load_bg_img()
        self.messages = messages.Messages(self.surface)

        self.platform = platform.Platform(self.surface)

        self.balls = [ball_class.Ball(self.surface)]

        self.load_map()
        self.block_left = level_map.get_bricks_to_destroy(self.map_blocks)

        self.lasers = []

        self.enemy_spawn_cooldown = 0
        self.list_enemies = []
        self.max_enemies = 3