Ejemplo n.º 1
0
    def createZombie(self):

        height = random.randrange(3)
        horizontal_position = random.randrange(2)
        new_zombie = Zombie()

        success = False

        while not success:
            ## position the zombies between invisible wall tiles and at proper heights
            if height == 0:
                new_zombie.bottom = 220

                if horizontal_position == 0:
                    new_zombie.center_x = random.randrange(30, 180)
                else:
                    new_zombie.center_x = random.randrange(760, 920)
            elif height == 1:
                new_zombie.bottom = 375
                if horizontal_position == 0:
                    new_zombie.center_x = random.randrange(130, 300)
                else:
                    new_zombie.center_x = random.randrange(640, 830)
            else:
                new_zombie.bottom = 527
                if horizontal_position == 0:
                    new_zombie.center_x = random.randrange(30, 240)
                else:
                    new_zombie.center_x = random.randrange(720, 920)

            hit_list = arcade.check_for_collision_with_list(
                new_zombie, self.enemy_list)

            if len(hit_list) == 0:
                success = True
            else:
                print('collision')

        # new_zombie.rect_outline = arcade.create_rectangle_outline(new_zombie.center_x, new_zombie.top + new_zombie.height * 0.1,
        #                                                new_zombie.hp_bar_width,
        #                                                new_zombie.hp_bar_height, new_zombie.hp_bar_outline_color, 2, 0)
        #
        # new_zombie.rect = arcade.create_rectangle_filled(new_zombie.center_pos, new_zombie.top + new_zombie.height * 0.1,
        #                                             (new_zombie.remaining_hp / new_zombie.total_hp) * new_zombie.hp_bar_width,
        #                                             new_zombie.hp_bar_height,
        #                                             new_zombie.hp_bar_color, 0)
        #
        # # self.hp_bar_list.append(rect_outline)
        # self.hp_bar_list.append(new_zombie.rect)
        # self.hp_bar_list.append(new_zombie.rect_outline)
        self.enemy_list.append(new_zombie)
        self.animated_list.append(new_zombie)