def __init__(self, x, y): self.enemy = enemies.Dragon() self.alive_text = self.enemy.alive_text self.dead_text = self.enemy.dead_text super().__init__(x, y)
def __init__(self,x, y): dragon = enemies.Dragon() super().__init__(x,y, dragon) self.key_taken = False
def add_enemies(frames, enemies_list, enemy_spawn_rate, difficulty): """Adds enemies to enemies_list, ramping up difficulty over time. Function adds an enemy object or group of enemy objects to the enemies_list at intervals pre-defined by enemy_spawn_rate (from settings). It picks which enemy or group of enemies to add with 'picker' variable which gets set purposefully or randomly with random.randint to a number defined by the game frames (time) in the game (modified through 'difficulty' setting). Enemies are then appended/extended to enemies_list based on the 'picker'. Args: frames (int): The number of game frames since start of game (estimates time) enemies_list (list of obj): A list for which to append/extend enemy objects onto enemy_spawn_rate (int): Difficulty setting that places interval of enemy spawn difficulty (int): difficulty setting that defines how quickly difficulty of enemy spawns ramps up """ # Define 'picker' variable picker = -1 # Change picker and add enemies at interval of enemy_spawn_rate if frames % enemy_spawn_rate == 0: # Define rate of 'picker' ramp up based on difficulty min_rate = minutes * difficulty # Set the 'picker' based on frames (time) past and difficulty if frames <= 0.2 * min_rate: picker = 0 if 0.2 * min_rate < frames <= .5 * min_rate: picker = 1 if 0.5 * min_rate < frames <= 1 * min_rate: picker = random.randint(2, 3) if 1 * min_rate < frames <= 2 * min_rate: picker = random.randint(3, 7) if 2 * min_rate < frames <= 2.9 * min_rate: picker = random.randint(8, 12) if 2.9 * min_rate < frames <= 3.5 * min_rate: pass if int((3 * min_rate) - (2 * seconds)) < frames <= \ int((3 * min_rate) + (2 * seconds)): picker = 13 if 3.5 * min_rate < frames <= 3.75 * min_rate: picker = random.randint(8, 12) if 3.75 * min_rate < frames <= 4.5 * min_rate: picker = random.randint(14, 18) if int((4 * min_rate) - (2 * seconds)) < frames <= \ int((4 * min_rate) + (2 * seconds)): picker = 13 if 4.5 * min_rate < frames <= 5 * min_rate: picker = random.randint(15, 19) if int((4.5 * min_rate) - (2 * seconds)) < frames <= \ int((4.5 * min_rate) + (2 * seconds)): picker = 20 if 5 * min_rate < frames <= 5.75 * min_rate: picker = random.randint(15, 20) if 5.75 * min_rate < frames <= 6.5 * min_rate: picker = random.randint(20, 24) if frames > 6.5 * min_rate: picker = random.randint(20, 24) # Append or extend list with enemies indicated by 'picker' if picker == -1: pass if picker == 0: enemies_list.append(enemies.Spider()) elif picker == 1: enemies_list.extend( [enemies.Spider(), enemies.Spider()]) elif picker == 2: enemies_list.extend( [enemies.Spider(), enemies.Spider(), enemies.Spider()]) elif picker == 3: enemies_list.append(enemies.Lizard()) elif picker == 4: enemies_list.append(enemies.Wolf()) elif picker == 5: enemies_list.append(enemies.Orc()) elif picker == 6: enemies_list.append(enemies.Turtle()) elif picker == 7: enemies_list.extend( [enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider()]) elif picker == 8: enemies_list.extend([enemies.Lizard(), enemies.Lizard()]) elif picker == 9: enemies_list.extend([enemies.Wolf(), enemies.Wolf()]) elif picker == 10: enemies_list.extend([enemies.Orc(), enemies.Orc()]) elif picker == 11: enemies_list.extend([enemies.Turtle(), enemies.Turtle()]) elif picker == 12: enemies_list.extend( [enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider()]) elif picker == 13: enemies_list.append(enemies.Dragon()) elif picker == 14: enemies_list.extend( [enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider()]) elif picker == 15: enemies_list.extend([enemies.Lizard(), enemies.Lizard(), enemies.Lizard()]) elif picker == 16: enemies_list.extend([enemies.Wolf(), enemies.Wolf(), enemies.Wolf()]) elif picker == 17: enemies_list.extend([enemies.Orc(), enemies.Orc(), enemies.Orc()]) elif picker == 18: enemies_list.extend([enemies.Turtle(), enemies.Turtle(), enemies.Turtle()]) elif picker == 19: enemies_list.extend( [enemies.Lizard(), enemies.Lizard(), enemies.Wolf(), enemies.Wolf(), enemies.Orc(), enemies.Orc(), enemies.Turtle(), enemies.Turtle(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider()]) elif picker == 20: enemies_list.extend([enemies.Dragon(), enemies.Dragon()]) elif picker == 21: enemies_list.extend([enemies.Lizard(), enemies.Lizard(), enemies.Lizard(), enemies.Lizard()]) elif picker == 22: enemies_list.extend([enemies.Wolf(), enemies.Wolf(), enemies.Wolf(), enemies.Wolf()]) elif picker == 23: enemies_list.extend([enemies.Orc(), enemies.Orc(), enemies.Orc(), enemies.Orc()]) elif picker == 24: enemies_list.extend([enemies.Turtle(), enemies.Turtle(), enemies.Turtle(), enemies.Turtle()]) elif picker == 25: enemies_list.extend( [enemies.Lizard(), enemies.Lizard(), enemies.Wolf(), enemies.Wolf(), enemies.Orc(), enemies.Orc(), enemies.Turtle(), enemies.Turtle(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider(), enemies.Spider()]) elif picker == 26: enemies_list.extend([enemies.Dragon(), enemies.Dragon(), enemies.Dragon()]) elif picker == 27: enemies_list.extend([enemies.Lizard(), enemies.Lizard(), enemies.Lizard(), enemies.Lizard(), enemies.Wolf(), enemies.Wolf()]) elif picker == 28: enemies_list.extend([enemies.Wolf(), enemies.Wolf(), enemies.Wolf(), enemies.Wolf(), enemies.Orc(), enemies.Orc()]) elif picker == 29: enemies_list.extend([enemies.Orc(), enemies.Orc(), enemies.Orc(), enemies.Orc(), enemies.Turtle(), enemies.Turtle()]) elif picker == 30: enemies_list.extend([enemies.Turtle(), enemies.Turtle(), enemies.Turtle(), enemies.Turtle(), enemies.Lizard(), enemies.Lizard()])
def __init__(self, x, y): super().__init__(x, y, enemies.Dragon())
def enemy_info_loop(): """Show and explain enemies with buttons to navigate Note: Texts located in gameText.py """ # Set buttons for page navigation return_button = generalClass.Button( (50, 50), message="Return", action=intro_loop, font_size=40, width=200, height=60, color1=orange, color2=bright_orange) previous_button = generalClass.Button( (50, display_height - 100), message="Previous", action="backward", font_size=40, width=200, height=60, color1=red, color2=bright_red) next_button = generalClass.Button( (600, display_height - 100), message="Next", action="forward", font_size=40, width=200, height=60, color1=green, color2=bright_green) # Set font font = pygame.font.SysFont('Comic Sans MS', 18, bold=True) # Set enemies, indicating stationary=True and destroy=False spider = enemies.Spider((180, 250), (190, 250), True, False) lizard = enemies.Lizard((180, 530), (190, 530), True, False) wolf = enemies.Wolf((180, 250), (190, 250), True, False) turtle = enemies.Turtle((180, 530), (190, 530), True, False) orc = enemies.Orc((180, 250), (190, 250), True, False) dragon = enemies.Dragon((180, 530), (190, 530), True, False) # Define index for page navigation info_index = 0 while True: # Activate quit button for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() # Draw background gameDisplay.blit(backgroundImage.image, backgroundImage.rect) pygame.draw.rect(gameDisplay, white, (100, 125, 650, 525)) # Draw buttons return_button.draw() next_enemy = next_button.draw() previous_enemy = previous_button.draw() # Define page navigation with index if next_enemy: info_index += 1 if previous_enemy: info_index -= 1 if info_index > 2: info_index = 0 if info_index < 0: info_index = 2 # Draw enemies and enemy info, pages indicated by index if info_index == 0: spider.draw() lizard.draw() helpers.blit_text(gameDisplay, spider_text, (275, 135), font, margin=125) helpers.blit_text(gameDisplay, lizard_text, (275, 400), font, margin=125) pygame.draw.rect(gameDisplay, black, (150, 385, 550, 5)) if info_index == 1: wolf.draw() turtle.draw() helpers.blit_text(gameDisplay, wolf_text, (275, 135), font, margin=125) helpers.blit_text(gameDisplay, turtle_text, (275, 400), font, margin=125) pygame.draw.rect(gameDisplay, black, (150, 385, 550, 5)) if info_index == 2: orc.draw() dragon.draw() helpers.blit_text(gameDisplay, orc_text, (275, 135), font, margin=125) helpers.blit_text(gameDisplay, dragon_text, (275, 400), font, margin=125) pygame.draw.rect(gameDisplay, black, (150, 385, 550, 5)) # Update game display pygame.display.update() clock.tick(30)