Пример #1
0
def create_world():
    global player, player_bullet
    global draw_score
    global scrolling_background
    global player_life
    global boss
    global boss_bullets

    boss_bullets = [BossBullet() for i in range(3)]
    boss_bullets[0].local = 0
    boss_bullets[1].local = 1
    boss_bullets[2].local = 2

    boss = Boss()
    boss.set_location(1,3)
    Timer_function(0)
    player_life = Player_life()

    scrolling_background = Background(800,600)

    draw_score = ScoreDraw()

    player = Player()

    # Generate enemies 60!


    player_bullet = Bullet()
Пример #2
0
    def spawnEnemies (self):

        spwn = self.spawner
        if spwn["spawn_counter"] >= spwn["spawn_delay"]:
            if len(Enemy.container) < spwn["max_enemies"]:
                if self.level -3 in range(3):
                    enemy = choice([Drone, Warship])(self.screensize,
                                                     self.player,
                                                     self.level)
                elif self.level > 6:
                    enemy = choice([Drone, Warship, Bomber])(self.screensize, 
                                                             self.player, 
                                                             self.level)
                else:
                    enemy = Drone(self.screensize, self.player, self.level)
                if self.level > 10:
                    enemy.armor["T"] *= 2
                    enemy.armor["M"] *= 2
                HealthBar(enemy, self.screen)
                spwn["spawn_counter"] = 0
        else:
            if not spwn["boss_out"]:
                spwn["spawn_counter"] += 1

        if spwn["enemy_killed"] >= spwn["max_enemies"]+(
                5+self.level*3) and (spwn["boss_out"] == False):
            sfx.stab.play()
            self.boss = Boss(self.screensize, self.player, self.level)
            self.boss.rect.midbottom = (self.screensize[0]/2, 0)
            spwn["enemy_killed"] = 0
            spwn["boss_out"] = True
            spwn["max_enemies"] += 1
            HealthBar(self.boss, self.screen)
Пример #3
0
def update():
    global frame
    global spawn_rate
    global boss_timer
    global boss_round
    global enemy_hp
    global enemy_count

    if boss_timer - get_time() > 0:
        boss_timer -= get_time()

    else:
        boss_round = True
    if not boss_round:
        if frame % spawn_rate == 0:
            frame = 1
            enemy_count = ((enemy_count + 1) % 7)
            spawn_rate = 90
            enemy = Enemy(enemy_hp)
            object.add_object(enemy, 0)
            if enemy_count == 0:
                enemy_hp += 40

    elif boss_round and len(object.objects[0]) == 0:
        enemy = Boss()
        object.add_object(enemy, 0)
    frame += 1
    for all_object in object.all_objects():
        all_object.update()
    buy_button.update()
    for d in dice:
        if d.unit is not None:
            d.unit.update()
Пример #4
0
def initGame():
    global gamepad, clock, fighter, bullet, boss ,shot, explosion
    # 게임이 진행될 게임 화면, 게임의 초당 프레임(FPS), 비행기 변수 선언, 적 선언
    global enemys, items
    pygame.init()
    gamepad = pygame.display.set_mode((pad_width, pad_height))  # 게임화면의 가로세로크기를 설정
    pygame.display.set_caption('Shooting Game')  # 게임화면의 제목 지정

    fighter = Fighter()
    for i in range(10):
        enemys.append(Enemy())

    items.append( HP_UP())
    items.append( POWER_UP())
    items.append( SCORE_UP())
    items.append( SUPER_POWER_UP())



    bullet = Bullet()
    boss = Boss()
    shot = pygame.image.load('image/shot.png')
    explosion = pygame.image.load('image/explosion.png')


    clock = pygame.time.Clock()  # 초당 프레임수를 설정할 수 있는 Clock객체 생성
Пример #5
0
    def boss_spawn(self):

        self.enemy_11 = Boss(self)
        self.enemy_11.setup("./characters/enemies/boss/png/boss",
                            CHARACTER_SCALING, 2500, 3200, BOSS)
        self.enemy_list.append(self.enemy_11)

        self.enemy_12 = Enemy(self)
        self.enemy_12.setup("./characters/enemies/antagonist/a",
                            CHARACTER_SCALING * 2.5, 2600, 3200, ANTAGONIST)
        self.antagonist_list.append(self.enemy_12)

        for player in self.player_list:
            player.change_x = 0
            player.change_y = 0
            player.center_x = 2300 + player.type * 100
            player.center_y = 2900
            player.facing_dir = 'UP'
Пример #6
0
 def handle_event(self, event):
     if event.type == QUIT:
         pygame.quit()
         quit()
     elif event.type == USEREVENT:
         self.terrain.enemy_group.add(Boss(self.terrain))
     elif event.type == KEYDOWN:
         if event.key == K_r:
             self.terrain.static_tower_group.empty()
             self.terrain.enemy_group.empty()
         elif event.key == K_DELETE:
             get_active(self.terrain.static_tower_group).kill()
Пример #7
0
    def level2Enemies1(self):
        self.enemy_1 = Enemy(self)
        self.enemy_1.setup("./characters/enemies/robo-1/robo",
                           CHARACTER_SCALING, 2200, 1200, MELEE)
        self.enemy_list.append(self.enemy_1)

        self.enemy_2 = Enemy(self)
        self.enemy_2.setup("./characters/enemies/robo-1/robo",
                           CHARACTER_SCALING, 1800, 1200, MELEE)
        self.enemy_list.append(self.enemy_2)

        self.enemy_3 = Enemy(self)
        self.enemy_3.setup("./characters/enemies/robo-1/robo",
                           CHARACTER_SCALING, 2000, 1500, MELEE)
        self.enemy_list.append(self.enemy_3)

        self.enemy_4 = Enemy(self)
        self.enemy_4.setup("./characters/enemies/robo-1/robo",
                           CHARACTER_SCALING, 2300, 2200, MELEE)
        self.enemy_list.append(self.enemy_4)

        self.enemy_5 = Turret(self)
        self.enemy_5.setup("./characters/enemies/turret/turret",
                           CHARACTER_SCALING, 2000, 1300, TURRET)
        self.enemy_list.append(self.enemy_5)

        self.enemy_6 = Turret(self)
        self.enemy_6.setup("./characters/enemies/turret/turret",
                           CHARACTER_SCALING, 2200, 1300, TURRET)
        self.enemy_list.append(self.enemy_6)

        self.enemy_7 = Turret(self)
        self.enemy_7.setup("./characters/enemies/turret/turret",
                           CHARACTER_SCALING, 2100, 2200, TURRET)
        self.enemy_list.append(self.enemy_7)

        self.enemy_8 = Boss(self)
        self.enemy_8.setup("./characters/enemies/robotgunner/turrent",
                           CHARACTER_SCALING * 2, 2000, 1600, RANGE)
        self.enemy_list.append(self.enemy_8)

        self.enemy_9 = Boss(self)
        self.enemy_9.setup("./characters/enemies/robotgunner/turrent",
                           CHARACTER_SCALING * 2, 2400, 2200, RANGE)
        self.enemy_list.append(self.enemy_9)

        self.enemy_10 = Boss(self)
        self.enemy_10.setup("./characters/enemies/robotgunner/turrent",
                            CHARACTER_SCALING * 2, 2400, 2000, RANGE)
        self.enemy_list.append(self.enemy_10)

        for enemy in self.enemy_list:
            self.physics_engines.append(
                arcade.PhysicsEngineSimple(
                    enemy,
                    self.blockable_list,
                ))
Пример #8
0
class Game:

    def __init__ (self):

        self.screensize   = self.assembleImages()
        self.screen       = pygame.display.set_mode(self.screensize, 0, 32)
        self.volume       = 0.5
        self.player       = SpaceShip(self.screensize)
        HealthBar(self.player, self.screen, True)
        self.clock        = pygame.time.Clock()
        self.level        = 1
        self.boss         = None
        self.font         = pygame.font.Font("GearsOfPeace.ttf", 12)
        self.med_font     = pygame.font.Font("GearsOfPeace.ttf", 30)
        self.big_font     = pygame.font.Font("GearsOfPeace.ttf", 50)
        self.notify       = {"msg": None, "timer": [60*3, 0]}
        self.spawner      = {"max_enemies": 2,
                             "enemy_killed": 0,
                             "spawn_delay": (60 * 2.2),
                             "spawn_counter": 0,
                             "boss_out": False,}
        self.running = True

    def openingScene (self):

        to_play = [sfx.AI_greeting, sfx.AI_mission]
        running = True
        for index, sound in enumerate(to_play):
            sound.play()
            while running:
                self.time_passed = self.clock.tick(60)/1000.0
                if not pygame.mixer.get_busy():
                    break
                for event in pygame.event.get():
                    if event.type == QUIT:
                        running = False
                        self.running = False
                        return
                    if event.type == KEYDOWN and event.key == K_ESCAPE:
                        running = False
                        sound.stop()
                        return
                
                self.manageSprite(Background.container)
                text = "SPACEBAR = FIRE ZE LASERS"
                surface = self.font.render(text, True, (255,255,255))
                self.screen.blit(surface, (self.screensize[0]/2-120, 250))
                text = "M = FIRE A MISSILE"
                surface = self.font.render(text, True, (255,255,255))
                self.screen.blit(surface, (self.screensize[0]/2-120, 280))
                text = "N = LAUNCH NUCLEAR WARHEAD"
                surface = self.font.render(text, True, (255,255,255))
                self.screen.blit(surface, (self.screensize[0]/2-120, 310))
                text = "E = EMP (Scorpion Upgrade Line)"
                surface = self.font.render(text, True, (255,255,255))
                self.screen.blit(surface, (self.screensize[0]/2-120, 340))
                text = "R = Repair (Collect Wrenches)"
                surface = self.font.render(text, True, (255,255,255))
                self.screen.blit(surface, (self.screensize[0]/2-120, 370))
                text = "PRESS Esc TO SKIP INTRO"
                surface = self.med_font.render(text, True, (255,255,255))
                self.screen.blit(surface, (self.screensize[0]/2-250, 450))
                self.manageSprite(self.player.container)
                pygame.display.flip()


    def assembleImages(self):

        image_path = os.path.join("backgrounds", choice(BACKGROUNDS))

        backgroundTL = ScrollingBackground(image_path)
        backgroundBL = ScrollingBackground(image_path)
        backgroundTL.rect.bottom = backgroundBL.rect.top
        width = backgroundTL.rect.width
        height = backgroundTL.rect.height

        global screenrect
        screenrect = Rect(0,0,backgroundTL.rect.width,backgroundTL.rect.height)
        display = pygame.display.Info()
        if display.current_h < 1000:
            height = display.current_h 
        return (width, height)

    def manageSprite (self, container):

        container.update(self.time_passed)
        container.draw(self.screen)

    def spawnEnemies (self):

        spwn = self.spawner
        if spwn["spawn_counter"] >= spwn["spawn_delay"]:
            if len(Enemy.container) < spwn["max_enemies"]:
                if self.level -3 in range(3):
                    enemy = choice([Drone, Warship])(self.screensize,
                                                     self.player,
                                                     self.level)
                elif self.level > 6:
                    enemy = choice([Drone, Warship, Bomber])(self.screensize, 
                                                             self.player, 
                                                             self.level)
                else:
                    enemy = Drone(self.screensize, self.player, self.level)
                if self.level > 10:
                    enemy.armor["T"] *= 2
                    enemy.armor["M"] *= 2
                HealthBar(enemy, self.screen)
                spwn["spawn_counter"] = 0
        else:
            if not spwn["boss_out"]:
                spwn["spawn_counter"] += 1

        if spwn["enemy_killed"] >= spwn["max_enemies"]+(
                5+self.level*3) and (spwn["boss_out"] == False):
            sfx.stab.play()
            self.boss = Boss(self.screensize, self.player, self.level)
            self.boss.rect.midbottom = (self.screensize[0]/2, 0)
            spwn["enemy_killed"] = 0
            spwn["boss_out"] = True
            spwn["max_enemies"] += 1
            HealthBar(self.boss, self.screen)

    def gameOver (self):

        # Do all the game over stuff here...
        self.running = False # True for debugging purposes - set to False to end game

    def playerDamage (self, enemy, projectiles):

        for proj in projectiles:
            proj.explode()
            if enemy.decreaseHealth(proj.damage) <= 0:
                if type(enemy).__name__ == "Guard":
                    self.boss.guards_out -= 1
                    self.player.exp += enemy.armor["M"]
                    enemy.die(sfx.muffled_explosion)
                    return
                self.spawner["enemy_killed"] += 1
                if type(enemy).__name__ == "Drone":
                    self.player.exp += enemy.armor["M"]+1
                else:
                    self.player.exp += enemy.armor["M"]
                chance = randint(1,13)
                if chance in [12, 13]:
                    new_powerup = Wrench()
                    new_powerup.rect.center = enemy.rect.center
                    PowerUpGlow(new_powerup)
                elif chance == 2:
                    new_powerup = Bullet()
                    new_powerup.rect.center = enemy.rect.center
                    PowerUpGlow(new_powerup)
                elif chance == 3:
                    new_powerup = MissileReload()
                    new_powerup.rect.center = enemy.rect.center
                    PowerUpGlow(new_powerup)
                elif chance == 4:
                    new_powerup = GunUpgrade()
                    new_powerup.rect.center = enemy.rect.center
                    PowerUpGlow(new_powerup)
                enemy.die(sfx.muffled_explosion)
                break

    def collisionCheck (self, collide):

        # Check if the player has shot an enemy (non boss)
        kpow = collide(Enemy.container, Fireball.container, False, True)
        if kpow:
            for enemy in kpow:
                self.playerDamage(enemy, kpow[enemy])
        # Check if an enemy has shot the player
        boom = collide(EnemyFireball.container, self.player.container, True, False)
        if boom:
            if self.player.decreaseHealth(1) <= 0:
                self.player.die()
        # Check if the player crashed into an enemy
        bang = collide(Enemy.container, self.player.container, False, False)
        if bang:
            for enemy in bang:
                e_armor = enemy.armor["T"]
                if type(enemy).__name__ == "Guard":
                    self.boss.guards_out -= 1
                enemy.die(sfx.muffled_explosion)
                if self.player.decreaseHealth(e_armor) <= 0:
                    self.player.die()
        # Check if the player has shot a boss
        bash = collide(Fireball.container, Boss.container, True, False)
        if bash:
            for projectile in bash:
                if not self.boss.invincible:
                    if self.boss.decreaseHealth(projectile.damage) <= 0:
                        self.spawner["boss_out"] = False
                        self.player.exp += self.boss.armor["M"]
                        self.level += 1
                        self.boss.die(sfx.muffled_explosion)
                        self.boss = None
                        self.player.ranks["remaining"] += 1
                        text = "New Upgrades! (Press ESC)"
                        self.notify["msg"] = self.med_font.render(text, True, (255,255,255))
                        break
                    projectile.explode()
        # Check if the player has grabbed a PowerUp
        ding = collide(PowerUp.container, self.player.container, True, False)
        if ding:
            for power in ding:
                power.effect(self.player)

    def showStats (self):

        fr = self.font.render
        if self.player.lives < 0:
            text = "Game Over..."
            surface = self.big_font.render(text, True, (255,255,255))
            self.screen.blit(surface, (200, self.screensize[1]/2-75))
            text = "EXP: %s -- LEVEL: %s" %(game.player.exp, game.level)
            surface = fr(text, True, (255,255,255))
            self.screen.blit(surface, (350, self.screensize[1]/2))
        else:
            text = "Level: %s" %(game.level)
            surface = fr(text, True, (255,255,255))
            self.screen.blit(surface, (10, 10))
            text = "EXP: %s" %(int(round(game.player.exp)))
            surface = fr(text, True, (255,255,255))
            self.screen.blit(surface, (10, 30))
            text = "Escape Pods: %s" %(game.player.lives)
            surface = fr(text, True, (255,255,255))
            self.screen.blit(surface, (10, 50))
            text = game.player.getHitPercentage()
            surface = fr(text, True, (255,255,255))
            self.screen.blit(surface, (10, 70))
            text = "Armor: %s/%s" % (game.player.armor["T"], game.player.armor["M"])
            surface = fr(text, True, (255,255,255))
            self.screen.blit(surface, (10, self.screensize[1]-50))
            text = "Missiles: %s" %(self.player.missiles)
            surface = fr(text, True, (255,255,255))
            self.screen.blit(surface, (self.screensize[0]-180, 10))
            text = "Repair Drones: %s" %(self.player.wrenches)
            surface = fr(text, True, (255,255,255))
            self.screen.blit(surface, (self.screensize[0]-180, 30))
            text = "Nukes: %s" %(game.player.nukes)
            surface = fr(text, True, (255,255,255))
            self.screen.blit(surface, (self.screensize[0]-180, 50))
            if self.player.missile:
                text = "NEXT MISSILE: 0:%s" %(round(game.player.missile_timer[1],1))
                surface = fr(text, True, (255,255,255))
                self.screen.blit(surface, (self.screensize[0]-180, 70))
            if self.player.emp:
                text = "NEXT EMP: 0:%s" %(round(game.player.emp["timer"][1],1))
                surface = fr(text, True, (255,255,255))
                self.screen.blit(surface, (self.screensize[0]-180, 90))


    def displayNotifications (self):

        if not self.notify["msg"]: return
        if self.notify["timer"][1] >= self.notify["timer"][0]:
            self.notify["msg"] = None
            self.notify["timer"][1] = 0
        else:
            self.screen.blit(self.notify["msg"], (275, int(self.screensize[1]/3-50)))
            self.notify["timer"][1] += 1

    def eventCheck(self, event):

        if event.type == QUIT:
            self.running = False
        if event.type == KEYDOWN:
            if event.key == K_p or event.key == K_ESCAPE: # Pause the game and open the menu
                self.menu = MainMenu(self)
                self.menu.run()
            if event.key == K_SPACE:
                self.player.shooting = True
            if event.key == K_UP:
                self.player.moving.add("forward")
            if event.key == K_DOWN:
                self.player.moving.add("back")
            if event.key == K_RIGHT:
                self.player.moving.add("right")
            if event.key == K_LEFT:
                self.player.moving.add("left")
            if event.key == K_e:
                if self.player.emp:
                    self.player.triggerEmp(self.screen, Enemy.container, self.boss)
            if event.key == K_m:
                self.player.missile(Enemy.container, self.boss)
            if event.key == K_n:
                self.player.nuke(self.screen, Enemy.container, self.boss)
            if event.key == K_r:
                self.player.repair()
            if event.key == K_EQUALS:
                self.volume += 0.1
                if self.volume > 1:
                    self.volume = 1.0
                pygame.mixer.music.set_volume(self.volume)
            if event.key == K_MINUS:
                self.volume -= 0.1
                if self.volume < 0:
                    self.volume = 0.0
                pygame.mixer.music.set_volume(self.volume)
        if event.type == KEYUP:
            if event.key == K_SPACE:
                self.player.shooting = False
            if event.key == K_UP:
                self.player.moving.remove("forward")
            if event.key == K_DOWN:
                self.player.moving.remove("back")
            if event.key == K_RIGHT:
                self.player.moving.remove("right")
            if event.key == K_LEFT:
                self.player.moving.remove("left")

    def run (self):

        #self.notify["msg"] = self.med_font.render("Pew Pew Space", True, (255,255,255))
        self.openingScene()

        sfx.play_music()
        collide = pygame.sprite.groupcollide

        while self.running:
            self.time_passed = self.clock.tick(60)/1000.0
            pygame.display.set_caption("[FPS -- %s]" %(int(self.clock.get_fps())))
            for event in pygame.event.get():
                self.eventCheck(event)

            self.spawnEnemies()
            self.manageSprite(Background.container)           # Background
            self.showStats()                                  # Stats
            self.displayNotifications()                       # Notifications
            self.manageSprite(Passive.container)              # Passive sprites
            self.manageSprite(Animation.container)            # Animations
            self.manageSprite(Fireball.container)             # Player's bullets
            self.manageSprite(Missile.container)              # Player missiles
            self.manageSprite(Boss.container)                 # Boss
            self.manageSprite(EnemyFireball.container)        # Enemy's bullets
            self.manageSprite(Enemy.container)                # Enemies
            self.manageSprite(HealthBar.container)            # Healthbars
            self.manageSprite(PowerUp.container)              # PowerUps
            self.manageSprite(self.player.container)          # Player
            self.collisionCheck(collide)                      # Collisions
            pygame.display.flip()                             # Update dislplay
Пример #9
0
class MyGame(arcade.Window):
    """
    Main application class.
    """
    def __init__(self):

        self.menu_sprite = None
        self.menu_sprites = None
        # Call the parent class and set up the window
        super().__init__(SCREEN_WIDTH,
                         SCREEN_HEIGHT,
                         SCREEN_TITLE,
                         resizable=True)

        # These are 'lists' that keep track of our sprites. Each sprite should
        # go into a list.
        self.wall_list = None
        self.player_list = None
        self.enemy_list = None
        self.dashable_list = None
        self.blockable_list = None
        self.antagonist_list = None
        self.health_pickup_list = None
        self.health_sprite = None

        self.can_control = None

        self.plot_text = None
        self.in_start_screen = None

        # Separate variable that holds the player sprite
        self.player = None
        self.enemy = None

        # Our physics engine
        self.physics_engines = None
        self.enemy_physics_engine = None

        # Used to keep track of our scrolling
        self.view_bottom = 0
        self.view_left = 0

        self.mouse_x = 160
        self.mouse_y = 0

        self.right_click = False

        #smooth camera
        self.view_target_left = self.view_left
        self.view_target_bottom = self.view_bottom

        arcade.set_background_color((0, 0, 0))

        self.state = None

        self.cutscene_timer = None
        self.player_idx = None
        self.story_idx = None
        self.level_sound = None

        # --- Load in a map from the tiled editor ---
    def load_level(self, path_to_map, path_to_level_sound, map_width,
                   map_height, tile_width, tile_height, tile_scale):
        """ Loads a level"""

        # Name of map file to load
        map_name = path_to_map
        # Name of the layer in the file that has our platforms/walls
        platforms_layer_name = 'Floor'
        platforms_wall_layer_name = 'Walls'
        platforms_dashable_layer_name = 'Dashable'
        platforms_props_layer_name = 'props'

        # Read in the tiled map
        my_map = arcade.tilemap.read_tmx(map_name)

        # -- Platforms
        self.wall_list = arcade.tilemap.process_layer(
            map_object=my_map,
            layer_name=platforms_wall_layer_name,
            scaling=TILE_SCALING,
            use_spatial_hash=True)

        self.floor_list = arcade.tilemap.process_layer(
            map_object=my_map,
            layer_name=platforms_layer_name,
            scaling=TILE_SCALING,
            use_spatial_hash=True)

        self.props_list = arcade.tilemap.process_layer(
            map_object=my_map,
            layer_name=platforms_props_layer_name,
            scaling=TILE_SCALING,
            use_spatial_hash=True)

        self.dashable_list = arcade.tilemap.process_layer(
            map_object=my_map,
            layer_name=platforms_dashable_layer_name,
            scaling=TILE_SCALING,
            use_spatial_hash=True)

        self.level_width = map_width * tile_width * tile_scale
        self.level_height = map_height * tile_height * tile_scale

        self.dashable_removed = None
        if self.level_sound == None:
            self.level_sound = arcade.load_sound(path_to_level_sound)
            pass

        # --- Other stuff
        # Set the background color
        if my_map.background_color:
            arcade.set_background_color(my_map.background_color)
        self.help_text = None

    def setup(self):
        """ Set up the game here. Call this function to restart the game. """

        # Used to keep track of our scrolling
        self.view_bottom = 0
        self.view_left = 0

        self.help_text = ""

        self.state = MENU
        self.cutscene_timer = 0
        self.can_control = False
        self.in_start_screen = True

        self.menu_sprite = arcade.Sprite('./effects/start-button.png')
        self.menu_sprites = arcade.SpriteList()
        self.menu_sprites.append(self.menu_sprite)

        self.dashable_removed = False

        # Create the Sprite lists
        self.player_list = arcade.SpriteList()
        self.enemy_list = arcade.SpriteList()
        self.floor_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()
        self.dashable_list = arcade.SpriteList()
        self.blockable_list = arcade.SpriteList()
        self.health_pickup_list = arcade.SpriteList()
        self.antagonist_list = arcade.SpriteList()

        self.player_idx = 0
        self.story_idx = 0

        self.load_level("./maps/level-1.tmx", "sounds/scores/level-1.mp3", 50,
                        50, 16, 16, TILE_SCALING)
        arcade.play_sound(self.level_sound)
        # Set up the player, specifically placing it at these coordinates.
        self.player = Player(self)
        self.second_player = Player(self)
        self.player.setup("./characters/cat", CHARACTER_SCALING, 550, 1020, 1)
        self.second_player.setup("./characters/cat", CHARACTER_SCALING, 3000,
                                 3400, 2)
        #self.third_player.setup("./characters/cat", CHARACTER_SCALING, 350, 400, 3)
        #self.fourth_player.setup("./characters/cat", CHARACTER_SCALING*1.2, 350, 416, 4)
        self.player_list.append(self.player)
        #self.player_list.append(self.second_player)
        #self.player_list.append(self.third_player)
        #self.player_list.append(self.fourth_player)
        self.health_sprite = arcade.Sprite('./effects/256px-Paw-print.svg.png',
                                           0.2)

        self.enemy = Turret(self)
        self.enemy.setup("./characters/enemies/turret/turret",
                         CHARACTER_SCALING, 2300, 300, TURRET)
        self.enemy_list.append(self.enemy)

        self.enemy_2 = Enemy(self)
        self.enemy_2.setup("./characters/enemies/robo-1/robo",
                           CHARACTER_SCALING, 3000, 300, MELEE)
        self.enemy_list.append(self.enemy_2)

        self.enemy_3 = Enemy(self)
        self.enemy_3.setup("./characters/enemies/robo-1/robo",
                           CHARACTER_SCALING, 2500, 1500, MELEE)
        self.enemy_list.append(self.enemy_3)

        self.enemy_3 = Enemy(self)
        self.enemy_3.setup("./characters/enemies/robo-1/robo",
                           CHARACTER_SCALING, 3000, 1560, MELEE)
        self.enemy_list.append(self.enemy_3)

        self.enemy_4 = Turret(self)
        self.enemy_4.setup("./characters/enemies/turret/turret",
                           CHARACTER_SCALING, 2800, 1660, TURRET)
        self.enemy_list.append(self.enemy_4)

        self.enemy_5 = Enemy(self)
        self.enemy_5.setup("./characters/enemies/robo-1/robo",
                           CHARACTER_SCALING, 3000, 1560, MELEE)
        self.enemy_list.append(self.enemy_5)

        self.enemy_6 = Turret(self)
        self.enemy_6.setup("./characters/enemies/turret/turret",
                           CHARACTER_SCALING, 2800, 1400, TURRET)
        self.enemy_list.append(self.enemy_6)

        for sprite in self.wall_list:
            self.blockable_list.append(sprite)
        for sprite in self.dashable_list:
            self.blockable_list.append(sprite)

        #health pickups
        health_1 = arcade.Sprite("./effects/hpa/hpa/hpa.png")
        health_2 = arcade.Sprite("./effects/hpa/hpa/hpa.png")
        health_1.center_x = 2700
        health_1.center_y = 1100
        self.health_pickup_list.append(health_1)

        health_2.center_x = 350
        health_2.center_y = 550
        self.health_pickup_list.append(health_2)

        for tile in self.floor_list:
            tile.color = [200, 200, 255]
        for tile in self.wall_list:
            tile.color = [200, 200, 255]
        for tile in self.wall_list:
            tile.color = [200, 200, 255]

        # Create the 'physics engine'
        self.physics_engines = []

        for player in self.player_list:
            if (player == self.player):
                self.physics_engines.append(
                    arcade.PhysicsEngineSimple(
                        player,
                        self.enemy_list,
                    ))

            else:
                self.physics_engines.append(
                    arcade.PhysicsEngineSimple(
                        player,
                        self.blockable_list,
                    ))

        for enemy in self.enemy_list:
            self.physics_engines.append(
                arcade.PhysicsEngineSimple(
                    enemy,
                    self.blockable_list,
                ))
        """
        self.physics_engine = arcade.PhysicsEngineSimple(self.player,
                                                            self.enemy_list
                                                             )
        """
        #self.enemy.barrier_list.recalculate()

    def setup_2(self):
        self.cutscene_timer = 0
        self.player_list = arcade.SpriteList()
        self.enemy_list = arcade.SpriteList()
        self.floor_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()
        self.dashable_list = arcade.SpriteList()
        self.blockable_list = arcade.SpriteList()
        self.health_pickup_list = arcade.SpriteList()

        self.load_level("./maps/level-3.tmx", "sounds/scores/level-1.mp3", 50,
                        50, 16, 16, TILE_SCALING)

        # Set up the player, specifically placing it at these coordinates.
        self.player = Player(self)
        self.second_player = Player(self)
        self.third_player = Player(self)
        self.fourth_player = Player(self)
        self.player.setup("./characters/cat", CHARACTER_SCALING, 2000, 200, 1)
        self.player.facing_dir = 'RIGHT'
        self.second_player.setup("./characters/cat", CHARACTER_SCALING, 2200,
                                 300, 2)
        self.second_player.facing_dir = 'LEFT'
        self.third_player.setup("./characters/cat", CHARACTER_SCALING, 2200,
                                100, 3)
        self.third_player.facing_dir = 'RIGHT'
        self.fourth_player.setup("./characters/cat", CHARACTER_SCALING * 1.2,
                                 2000, 400, 4)
        self.fourth_player.facing_dir = 'DOWN'

        self.state = CUTSCENE_3
        self.story_idx = 17
        #self.third_player.setup("./characters/cat", CHARACTER_SCALING, 350, 400, 3)
        #self.fourth_player.setup("./characters/cat", CHARACTER_SCALING*1.2, 350, 416, 4)
        self.player_list.append(self.player)
        self.player_list.append(self.second_player)
        self.player_list.append(self.third_player)
        self.player_list.append(self.fourth_player)

        self.health_sprite = arcade.Sprite('./effects/256px-Paw-print.svg.png',
                                           0.2)

        for sprite in self.wall_list:
            self.blockable_list.append(sprite)

        for player in self.player_list:

            self.physics_engines.append(
                arcade.PhysicsEngineSimple(
                    player,
                    self.blockable_list,
                ))

    def level2Enemies1(self):
        self.enemy_1 = Enemy(self)
        self.enemy_1.setup("./characters/enemies/robo-1/robo",
                           CHARACTER_SCALING, 2200, 1200, MELEE)
        self.enemy_list.append(self.enemy_1)

        self.enemy_2 = Enemy(self)
        self.enemy_2.setup("./characters/enemies/robo-1/robo",
                           CHARACTER_SCALING, 1800, 1200, MELEE)
        self.enemy_list.append(self.enemy_2)

        self.enemy_3 = Enemy(self)
        self.enemy_3.setup("./characters/enemies/robo-1/robo",
                           CHARACTER_SCALING, 2000, 1500, MELEE)
        self.enemy_list.append(self.enemy_3)

        self.enemy_4 = Enemy(self)
        self.enemy_4.setup("./characters/enemies/robo-1/robo",
                           CHARACTER_SCALING, 2300, 2200, MELEE)
        self.enemy_list.append(self.enemy_4)

        self.enemy_5 = Turret(self)
        self.enemy_5.setup("./characters/enemies/turret/turret",
                           CHARACTER_SCALING, 2000, 1300, TURRET)
        self.enemy_list.append(self.enemy_5)

        self.enemy_6 = Turret(self)
        self.enemy_6.setup("./characters/enemies/turret/turret",
                           CHARACTER_SCALING, 2200, 1300, TURRET)
        self.enemy_list.append(self.enemy_6)

        self.enemy_7 = Turret(self)
        self.enemy_7.setup("./characters/enemies/turret/turret",
                           CHARACTER_SCALING, 2100, 2200, TURRET)
        self.enemy_list.append(self.enemy_7)

        self.enemy_8 = Boss(self)
        self.enemy_8.setup("./characters/enemies/robotgunner/turrent",
                           CHARACTER_SCALING * 2, 2000, 1600, RANGE)
        self.enemy_list.append(self.enemy_8)

        self.enemy_9 = Boss(self)
        self.enemy_9.setup("./characters/enemies/robotgunner/turrent",
                           CHARACTER_SCALING * 2, 2400, 2200, RANGE)
        self.enemy_list.append(self.enemy_9)

        self.enemy_10 = Boss(self)
        self.enemy_10.setup("./characters/enemies/robotgunner/turrent",
                            CHARACTER_SCALING * 2, 2400, 2000, RANGE)
        self.enemy_list.append(self.enemy_10)

        for enemy in self.enemy_list:
            self.physics_engines.append(
                arcade.PhysicsEngineSimple(
                    enemy,
                    self.blockable_list,
                ))

    def setup_post_cut_scene(self):
        self.physics_engines[self.player_idx] = arcade.PhysicsEngineSimple(
            self.player, self.blockable_list)

    def on_draw(self):
        """ Render the screen. """
        arcade.start_render()

        if (self.state == END):
            arcade.draw_text(
                "The purrtecters destroyed the evil machine\nAnd restored society to normal",
                10 + self.view_left,
                10 + self.view_bottom + SCREEN_HEIGHT / 2,
                arcade.csscolor.WHITE,
                50,
                bold=True)
            return

        # Draw our sprites
        self.floor_list.draw()
        self.dashable_list.draw()
        self.wall_list.draw()
        self.player_list.draw()
        self.enemy_list.draw()
        self.props_list.draw()
        self.health_pickup_list.draw()
        self.antagonist_list.draw()

        for enemy in self.enemy_list:
            enemy.bullet_list.draw()

        self.player.hud_sprite.left = self.view_left
        self.player.hud_sprite.bottom = self.view_bottom + BLACK_BAR_HEIGHT
        self.player.hud_sprite.draw()

        for player in self.player_list:
            player.bullet_list.draw()
            if (player.explosion_happening):
                player.explosion_index += .5
                if player.explosion_index >= len(player.explosion_sprites):
                    player.explosion_happening = False
                    player.explosion_index = 0
                else:
                    player.explosion_sprites[int(
                        player.explosion_index)].draw()

        if self.player.melee_attacking:
            self.player.melee_list.draw()

        if self.player.projectile_state:
            arcade.draw_circle_filled(self.mouse_x + self.view_left,
                                      self.mouse_y + self.view_bottom, 100,
                                      (100, 149, 237, 50))

        for i in range(self.player.health):
            self.health_sprite.left = self.view_left + 10 + i * (
                self.health_sprite.width + 10)
            self.health_sprite.bottom = self.view_bottom + SCREEN_HEIGHT - BLACK_BAR_HEIGHT - self.health_sprite.height - 10
            self.health_sprite.draw()

        rect = arcade.create_rectangle_filled(
            self.view_left + SCREEN_WIDTH / 2,
            self.view_bottom + BLACK_BAR_HEIGHT / 2, SCREEN_WIDTH,
            BLACK_BAR_HEIGHT, (0, 0, 0))
        rect_top = arcade.create_rectangle_filled(
            self.view_left + SCREEN_WIDTH / 2,
            self.view_bottom + SCREEN_HEIGHT - BLACK_BAR_HEIGHT / 2,
            SCREEN_WIDTH, BLACK_BAR_HEIGHT, (0, 0, 0))
        """
        rect = arcade.create_rectangle_filled(self.player.center_x, 
                self.player.center_y, SCREEN_WIDTH, BLACK_BAR_HEIGHT,
                (0,0,0))
        """
        rect.draw()
        rect_top.draw()

        self.plot_text = [
            "The cats and the hoomans lived in harmony",
            "But one sudden evening, something stranged happened!",
            "Cat: I don't understand, why was I thrown out?",
            "Cat: I'm weak. I need to find something to heal",
            "Cat: That's a lot better! I need to figure out what's going on.",
            "Cat: Maybe I can dash over that hole \nPress Shift to Dash", "",
            "Cat: Oh no! Danger Ahead!\nRight click to scratch",
            "I think I can salvage the robot's laser \nLeft click to shoot laser",
            "Why are there so many robots?!",
            "Cat Two: Wow! You seem to be good at this!",
            "One: WHAT THE HECK IS GOING ON?!", "TWO: Everyone hates us now",
            "TWO: ...we have to fight for our lives",
            "TWO: You coming with me?", "ONE: umm...",
            "TWO: Unless you wanna hide here forever..", "ONE: ok...",
            "TWO: ok, you're in for a treat...meet..",
            "TWO: Heavy cat….he's the best with guns..and nobody \n has ever gone through his shield",
            "TWO: Support cat….without him we we'd be dead somewhere, \nhe heals and throws bombs to get us to safety",
            "TWO: Aaand yours truly, I can become invisible and sneak up\non enemies and take them out before they know what hit em",
            "FOUR: so...what're you good at.?",
            "ONE: NOTHING, I'm just a house cat! I still have no idea \nwhat's going on",
            "ONE: well..there's been rumours that this weird guy's \nresponsible for all this...",
            "???: you've been causing a lot of trouble for me,\nand so you shall die, muahahahahahaha",
            "THREE: Who was that? Lets check it out!\nPRESS SPACE TO SWITCH BETWEEN DIFFERENT CATS",
            "???: You piece of turds decided that you can \nfeast on my beloved Ronny",
            "???: ...oh Ronny...what a beauty she was…", "???: FINISH THEM!!",
            "ONE: so.. who's Ronnie?",
            "???: HOW DARE YOU SAY THAT NAME? she….she was my family..",
            "???: and you turds take advantage of the fact the she flew away\n to eat a berry she found...",
            "???: little did she know that that would be her last..",
            "TWO: wait, ronnie's….a BIRD?",
            "???: AN EXOTIC GREY PARROT SHE WAS YOU DIMWIT...\nyou don't deserve to exist...",
            "???: So I created the purr-minator...",
            "???: designed to rid the world of the 4 legged \nrodents that have the previlige to be called...cats",
            "???: it's a state of the art machine that feeds off of \nmy feline detesting mind waves, ",
            "???: amplifies it and broadcasts it to the entire world",
            "THREE: Well too bad it ends here", "???: wait... NOoooo...", ""
        ]

        # Draw our health on the screen, scrolling it with the viewport
        health_text = f"{self.player.help_text}"
        health_text_2 = f"{self.player.info}"
        arcade.draw_text(health_text,
                         10 + self.view_left,
                         10 + self.view_bottom,
                         arcade.csscolor.WHITE,
                         23,
                         bold=True)
        arcade.draw_text(self.plot_text[self.story_idx],
                         10 + self.view_left,
                         80 + self.view_bottom,
                         arcade.csscolor.WHITE,
                         27,
                         bold=True)
        if (self.state == CUTSCENE_1 or self.state == CUTSCENE_2
                or self.state == CUTSCENE_3 or self.state == CUTSCENE_4
                or self.state == CUTSCENE_5):
            arcade.draw_text("PRESS SPACE TO SKIP DIALOGUE",
                             10 + self.view_left,
                             10 + self.view_bottom + SCREEN_HEIGHT -
                             BLACK_BAR_HEIGHT,
                             arcade.csscolor.WHITE,
                             27,
                             bold=True)

        else:
            arcade.draw_text(self.player.info,
                             10 + self.view_left,
                             10 + self.view_bottom + SCREEN_HEIGHT -
                             BLACK_BAR_HEIGHT,
                             arcade.csscolor.WHITE,
                             27,
                             bold=True)
        if (self.state == END):
            arcade.draw_text(
                "The purrtecters destroyed the evil machine\nAnd restored society to normal",
                10 + self.view_left,
                10 + self.view_bottom + SCREEN_HEIGHT - BLACK_BAR_HEIGHT,
                arcade.csscolor.WHITE,
                50,
                bold=True)

        if self.state == MENU:
            self.menu_sprite.center_x = self.view_left + SCREEN_WIDTH / 2
            self.menu_sprite.center_y = self.view_bottom + SCREEN_HEIGHT / 2
            self.menu_sprites.draw()

    def boss_spawn(self):

        self.enemy_11 = Boss(self)
        self.enemy_11.setup("./characters/enemies/boss/png/boss",
                            CHARACTER_SCALING, 2500, 3200, BOSS)
        self.enemy_list.append(self.enemy_11)

        self.enemy_12 = Enemy(self)
        self.enemy_12.setup("./characters/enemies/antagonist/a",
                            CHARACTER_SCALING * 2.5, 2600, 3200, ANTAGONIST)
        self.antagonist_list.append(self.enemy_12)

        for player in self.player_list:
            player.change_x = 0
            player.change_y = 0
            player.center_x = 2300 + player.type * 100
            player.center_y = 2900
            player.facing_dir = 'UP'

    def on_mouse_press(self, x, y, button, modifiers):
        isMenu = arcade.get_sprites_at_point(
            (x + self.view_left, y + self.view_bottom), self.menu_sprites)
        if len(isMenu) > 0:
            self.state = CUTSCENE_1

        if not self.can_control:
            return
        if button == arcade.MOUSE_BUTTON_RIGHT:
            self.player.melee()
        elif button == arcade.MOUSE_BUTTON_LEFT:
            if self.player.type == 1 or self.player.type == 4:
                self.player.range(x, y, self.view_left, self.view_bottom)
            elif self.player.type == 2:
                if (self.player.projectile_state):
                    self.player.range(x, y, self.view_left, self.view_bottom)
                else:
                    self.player.heal(x + self.view_left, y + self.view_bottom,
                                     self.player_list)
            elif self.player.type == 3:
                self.help_text = self.player.sneak_kill(
                    x + self.view_left, y + self.view_bottom, self.enemy_list)

    def on_mouse_motion(self, x, y, dx, dy):
        #position of mouse relative to palyer
        self.mouse_x = x
        self.mouse_y = y

    def on_mouse_release(self, x, y, button, modifiers):
        if not self.can_control:
            return
        if button == arcade.MOUSE_BUTTON_RIGHT:
            self.right_click = False
            self.player.change_x = 0
            self.player.change_y = 0

    def on_key_press(self, key, modifiers):
        if (not self.can_control and key != 32) or (self.player.dead
                                                    and key != 32):
            return
        """Called whenever a key is pressed. """

        if key == arcade.key.UP or key == arcade.key.W:
            self.player.change_y = self.player.movement_speed
            self.player.direction_y = self.player.movement_speed
            if self.player.change_x == 0:
                self.player.direction_x = 0
        elif key == arcade.key.DOWN or key == arcade.key.S:
            self.player.change_y = -self.player.movement_speed
            self.player.direction_y = -self.player.movement_speed
            if self.player.change_x == 0:
                self.player.direction_x = 0
        elif key == arcade.key.LEFT or key == arcade.key.A:
            self.player.change_x = -self.player.movement_speed
            self.player.direction_x = -self.player.movement_speed
            if self.player.change_y == 0:
                self.player.direction_y = 0
        elif key == arcade.key.RIGHT or key == arcade.key.D:
            self.player.change_x = self.player.movement_speed
            self.player.direction_x = self.player.movement_speed
            if self.player.change_y == 0:
                self.player.direction_y = 0
        elif key == 65505:
            """shift"""

            if (self.player.type == 1):

                if not self.dashable_removed:
                    for sprite in self.dashable_list:
                        self.blockable_list.remove(sprite)
                self.dashable_removed = True

                dash = self.player.dash()
                #if(dash!=(self.player.center_x,self.player.center_y) and arcade.has_line_of_sight((self.player.center_x,self.player.center_y),dash,self.wall_list)):
                #        self.player.center_x,self.player.center_y = dash

            elif (self.player.type == 2):
                self.player.projectile_state = True

            elif self.player.type == 3:
                self.player.invisible()

        elif key == 32:  #space
            if (self.state == CUTSCENE_1 or self.state == CUTSCENE_2
                    or self.state == CUTSCENE_3 or self.state == CUTSCENE_4
                    or self.state == CUTSCENE_5):
                self.cutscene_timer += 4
            else:
                #stop motion
                self.player.change_x = 0
                self.player.change_y = 0

                #make selected
                self.player_idx += 1
                if self.player_idx >= len(self.player_list):
                    self.player_idx = 0
                self.player = self.player_list[self.player_idx]

    def on_key_release(self, key, modifiers):
        if not self.can_control:
            return
        """Called when the user releases a key. """

        if key == arcade.key.LEFT or key == arcade.key.A:
            self.player.change_x = 0
            if self.player.change_y != 0:
                self.player.direction_x = 0
        elif key == arcade.key.RIGHT or key == arcade.key.D:
            self.player.change_x = 0
            if self.player.change_y != 0:
                self.player.direction_x = 0
        elif key == arcade.key.DOWN or key == arcade.key.S:
            self.player.change_y = 0
            if self.player.change_x != 0:
                self.player.direction_y = 0
        elif key == arcade.key.UP or key == arcade.key.W:
            self.player.change_y = 0
            if self.player.change_x != 0:
                self.player.direction_y = 0

    def update_scroll(self):
        changed_left = False
        changed_bottom = False

        # Scroll left
        left_boundary = self.view_left + LEFT_VIEWPORT_MARGIN
        if self.player.left < left_boundary and left_boundary > 0:
            self.view_target_left = -left_boundary + self.player.left
            changed_left = True

        # Scroll right
        right_boundary = self.view_left + SCREEN_WIDTH - RIGHT_VIEWPORT_MARGIN
        if self.player.right > right_boundary and right_boundary < self.level_width - RIGHT_VIEWPORT_MARGIN:
            self.view_target_left = self.player.right - right_boundary
            changed_left = True

        # Scroll up
        top_boundary = self.view_bottom + SCREEN_HEIGHT - TOP_VIEWPORT_MARGIN - BLACK_BAR_HEIGHT
        if self.player.top > top_boundary:
            self.view_target_bottom = self.player.top - top_boundary
            changed_bottom = True

        # Scroll down
        bottom_boundary = self.view_bottom + BOTTOM_VIEWPORT_MARGIN + BLACK_BAR_HEIGHT
        if self.player.bottom < bottom_boundary:
            self.view_target_bottom = -bottom_boundary + self.player.bottom
            changed_bottom = True

        if changed_bottom == False:
            self.view_target_bottom = 0

        if changed_left == False:
            self.view_target_left = 0

        if self.view_target_bottom != self.view_bottom or self.view_target_left != self.view_left:
            # Only scroll to integers. Otherwise we end up with pixels that
            # don't line up on the screen
            self.view_left += self.view_target_left / 10
            self.view_bottom += self.view_target_bottom / 10

            self.view_bottom = int(self.view_bottom)
            self.view_left = int(self.view_left)

            self.view_left = max(0, self.view_left)
            self.view_left = min(self.view_left,
                                 self.level_width - SCREEN_WIDTH)

            self.view_bottom = max(-BLACK_BAR_HEIGHT, self.view_bottom)
            self.view_bottom = min(
                self.view_bottom,
                self.level_height + 2 * BLACK_BAR_HEIGHT - SCREEN_HEIGHT)

            # Do the scrolling
            arcade.set_viewport(self.view_left, SCREEN_WIDTH + self.view_left,
                                self.view_bottom,
                                SCREEN_HEIGHT + self.view_bottom)

    def animate_cutscene_1(self, delta_time):
        self.player.canRange = False
        self.cutscene_timer += delta_time
        if (self.cutscene_timer == delta_time):
            self.player.set_brightness(0)
            self.player.health = 5
            self.player.movement_speed = 1

        if (self.cutscene_timer > 5):
            self.story_idx = 1

        if (self.cutscene_timer > 7):
            self.player.health = 2
            brightness = self.player.color[0]
            brightness += 10
            if (brightness > 255):
                brightness = 255
            self.player.set_brightness(brightness)
            self.player.change_angle = 4.9
            self.player.change_x = -5
            self.player.change_y = 0

        if self.cutscene_timer > 8.2:
            self.player.change_angle = 0
            self.player.angle = 0
            self.player.change_y = 0
            self.player.change_x = 0

            self.can_control = True

            self.state = PLAYTHROUGH_1
            self.setup_post_cut_scene()
            self.cutscene_timer = 0
            self.story_idx = 2

    def playthrough_1(self, delta_time):
        self.cutscene_timer += delta_time
        if self.cutscene_timer > 6:
            self.story_idx = 3
            self.state = PLAYTHROUGH_2
            self.cutscene_timer = 0

    def playthrough_2(self, delta_time):
        if self.player.health == self.player.max_health:
            self.story_idx = 4
            self.state = PLAYTHROUGH_3
        self.playthrough_3(delta_time)

    def playthrough_3(self, delta_time):
        if self.player.center_x > 794:
            self.story_idx = 5
            self.state = PLAYTHROUGH_4

    def playthrough_4(self, delta_time):
        if self.player.center_x > 1159:
            self.story_idx = 6
            self.state = PLAYTHROUGH_5

    def playthrough_5(self, delta_time):
        if self.player.center_x > 1350:
            self.story_idx = 7
        pass

    def playthrough_7(self, delta_time):
        if self.player.center_x > 2700 and self.player.center_y > 2000:
            self.story_idx = 9
            self.state = CUTSCENE_2
        pass

    def animate_cutscene_2(self, delta_time):
        self.player.change_x = 0
        self.player.change_y = 0
        self.second_player.change_x = 0
        self.second_player.change_y = 0
        self.cutscene_timer += delta_time
        self.can_control = False
        self.player_list.append(self.second_player)
        self.physics_engines.append(
            arcade.PhysicsEngineSimple(
                self.second_player,
                self.blockable_list,
            ))
        if self.second_player.center_x < self.player.left:
            self.second_player.change_x = PLAYER_MOVEMENT_SPEED
        elif self.second_player.center_x > self.player.left + self.player.width:
            self.second_player.change_x = -PLAYER_MOVEMENT_SPEED
        else:
            self.second_player.change_x = 0

        if self.second_player.center_y > self.player.bottom + self.player.height * 3:
            self.second_player.change_y = -PLAYER_MOVEMENT_SPEED
        else:
            self.second_player.change_y = 0
        if (self.cutscene_timer > 4):
            self.story_idx = 10
        if (self.cutscene_timer > 8):
            self.story_idx = 11
        if (self.cutscene_timer > 12):
            self.story_idx = 12
        if (self.cutscene_timer > 16):
            self.story_idx = 13
        if (self.cutscene_timer > 20):
            self.story_idx = 14
        if (self.cutscene_timer > 24):
            self.story_idx = 15
        if (self.cutscene_timer > 28):
            self.story_idx = 16
        if (self.cutscene_timer > 32):
            self.story_idx = 17
        if self.cutscene_timer > 36:
            self.setup_2()
            self.cutscene_timer = 0
            self.state = CUTSCENE_3

    def animate_cutscene_3(self, delta_time):
        self.cutscene_timer += delta_time
        self.can_control = False
        if (self.cutscene_timer > 4):
            self.story_idx = 18
        if (self.cutscene_timer > 8):
            self.story_idx = 19
        if (self.cutscene_timer > 12):
            self.story_idx = 20
        if (self.cutscene_timer > 16):
            self.story_idx = 21
        if (self.cutscene_timer > 20):
            self.story_idx = 22
        if (self.cutscene_timer > 24):
            self.story_idx = 23
        if (self.cutscene_timer > 26):
            self.story_idx = 24
        if (self.cutscene_timer > 29):
            self.second_player.explosion(SCREEN_WIDTH / 3,
                                         SCREEN_HEIGHT - BLACK_BAR_HEIGHT,
                                         self.view_left, self.view_bottom)
        if (self.cutscene_timer > 30):
            self.story_idx = 25
        if (self.cutscene_timer > 34):
            self.story_idx = 26
            self.state = PLAYTHROUGH_8
            self.can_control = True
            self.level2Enemies1()

    def playthrough_8(self):
        for enemy in self.enemy_list:
            if not enemy.dead:
                return

        self.state = CUTSCENE_4
        self.cutscene_timer = 0
        self.boss_spawn()

    def animate_cutscene_4(self, delta_time):
        self.can_control = False
        self.cutscene_timer += delta_time

        if self.cutscene_timer > 4:
            self.story_idx = 27
        if self.cutscene_timer > 8:
            self.story_idx = 28
        if self.cutscene_timer > 12:
            self.story_idx = 29
            self.can_control = True
            self.state = PLAYTHROUGH_9
            self.cutscene_timer = 0
            self.physics_engines.append(
                arcade.PhysicsEngineSimple(
                    self.enemy_11,
                    self.blockable_list,
                ))

    def playthrough_9(self):
        for enemy in self.enemy_list:
            if not enemy.dead:
                return

        self.state = CUTSCENE_5
        self.cutscene_timer = 0
        for player in self.player_list:
            player.change_x = 0
            player.change_y = 0
            player.center_x = 2300 + player.type * 100
            player.center_y = 2900
            player.facing_dir = 'UP'

    def animate_cutscene_5(self, delta_time):
        self.can_control = False
        self.cutscene_timer += delta_time

        if self.cutscene_timer > 4:
            self.story_idx = 30
        if self.cutscene_timer > 8:
            self.story_idx = 31
        if self.cutscene_timer > 12:
            self.story_idx = 32
        if self.cutscene_timer > 16:
            self.story_idx = 33
        if self.cutscene_timer > 20:
            self.story_idx = 34
        if self.cutscene_timer > 24:
            self.story_idx = 35
        if self.cutscene_timer > 28:
            self.story_idx = 36
        if self.cutscene_timer > 32:
            self.story_idx = 37
        if self.cutscene_timer > 36:
            self.story_idx = 38
        if self.cutscene_timer > 40:
            self.story_idx = 39
        if self.cutscene_timer > 44:
            self.story_idx = 40
        if self.cutscene_timer > 48:
            self.story_idx = 41
        if self.cutscene_timer > 52:
            self.story_idx = 42
            self.state = END

    def on_update(self, delta_time):

        if (self.dashable_removed and self.player.dash_timer == 0):
            self.dashable_removed = False

            for sprite in self.dashable_list:
                self.blockable_list.append(sprite)
        #print (self.player.center_x)

        self.update_scroll()
        for enemy in self.enemy_list:
            enemy.bullet_list.update()

        for player in self.player_list:
            player.update_animation()
            player.update()
            player.bullet_list.update()

        if (self.state == CUTSCENE_1):
            self.animate_cutscene_1(delta_time)
        elif (self.state == PLAYTHROUGH_1):
            self.playthrough_1(delta_time)
        elif (self.state == PLAYTHROUGH_2):
            self.playthrough_2(delta_time)
        elif (self.state == PLAYTHROUGH_3):
            self.playthrough_3(delta_time)
        elif (self.state == PLAYTHROUGH_4):
            self.playthrough_4(delta_time)
        elif (self.state == PLAYTHROUGH_5):
            self.playthrough_5(delta_time)
        elif (self.state == PLAYTHROUGH_7):
            self.playthrough_7(delta_time)
        elif (self.state == CUTSCENE_2):
            self.animate_cutscene_2(delta_time)
        elif (self.state == CUTSCENE_3):
            self.animate_cutscene_3(delta_time)
        elif self.state == PLAYTHROUGH_8:
            self.playthrough_8()
        elif (self.state == CUTSCENE_4):
            self.animate_cutscene_4(delta_time)
        elif (self.state == PLAYTHROUGH_9):
            self.playthrough_9()
        elif (self.state == CUTSCENE_5):
            self.animate_cutscene_5(delta_time)

        # self.enemy.move()

        for player in self.player_list:
            for bullet in player.bullet_list:
                wall_hit_list = arcade.check_for_collision_with_list(
                    bullet, self.wall_list)
                enemy_hit_list = arcade.check_for_collision_with_list(
                    bullet, self.enemy_list)

                if len(wall_hit_list) > 0 or len(enemy_hit_list) > 0:
                    bullet.remove_from_sprite_lists()

                for enemy in enemy_hit_list:
                    enemy.getDamaged(bullet.center_x, bullet.center_y)

                if bullet.bottom > self.view_bottom + self.height or bullet.top < 0 or bullet.right < 0 or bullet.left > self.view_left + self.width:
                    bullet.remove_from_sprite_lists()

            if player.explosion_happening:
                enemy_hit_list = arcade.check_for_collision_with_list(
                    player.explosion_sprites[int(player.explosion_index)],
                    self.enemy_list)
                for enemy in enemy_hit_list:
                    enemy.getDamaged(
                        player.explosion_sprites[int(
                            player.explosion_index)].center_x,
                        player.explosion_sprites[int(
                            player.explosion_index)].center_y)

        for e in self.enemy_list:
            for bullet in e.bullet_list:
                wall_hit_list = arcade.check_for_collision_with_list(
                    bullet, self.wall_list)
                enemy_hit_list = arcade.check_for_collision(
                    bullet, self.player)

        for enemy in self.enemy_list:
            for bullet in enemy.bullet_list:
                wall_hit_list = arcade.check_for_collision_with_list(
                    bullet, self.wall_list)
                enemy_hit_list = arcade.check_for_collision(
                    bullet, self.player)

                if len(wall_hit_list) > 0 or enemy_hit_list:
                    bullet.remove_from_sprite_lists()

                if enemy_hit_list:
                    self.player.getDamaged(bullet.center_x, bullet.center_y)
                if len(wall_hit_list) > 0 or enemy_hit_list:
                    bullet.remove_from_sprite_lists()

                if enemy_hit_list:
                    self.player.getDamaged(enemy.center_x, enemy.center_y)

                if bullet.bottom > self.view_bottom + self.height or bullet.top < 0 or bullet.right < 0 or bullet.left > self.view_left + self.width:
                    bullet.remove_from_sprite_lists()

        for health in self.health_pickup_list:
            pickup = arcade.check_for_collision(health, self.player)
            if pickup:
                health.remove_from_sprite_lists()
                self.player.health_pickup()

        hit_list = arcade.check_for_collision_with_list(
            self.player, self.enemy_list)
        for enemy in hit_list:
            if enemy.path_traversal_state == 'ATTACK' or enemy.path_traversal_state == 'SHOOT' or enemy.path_traversal_state == 'MELEE':
                self.player.getDamaged(enemy.center_x, enemy.center_y)
                enemy.deagro()

        if self.player.melee_attacking:
            hit_list = arcade.check_for_collision_with_list(
                self.player.melee_sprite[self.player.melee_idx],
                self.enemy_list)

            for enemy in hit_list:
                enemy.getDamaged(self.player.center_x, self.player.center_y)
        """
        if(self.level_sound.is_complete()):
            arcade.play_sound(self.level_sound)
        """

        for physics_engine in self.physics_engines:
            physics_engine.update()
        #self.enemy_physics_engine.update()

        for enemy in self.enemy_list:
            enemy.update()
            enemy.update_animation()

        #print(self.enemy.path)
        #print(self.player.center_x,self.player.center_y)

    def on_resize(self, width, height):
        """ This method is automatically called when the window is resized. """

        # Call the parent. Failing to do this will mess up the coordinates, and default to 0,0 at the center and the
        # edges being -1 to 1.
        super().on_resize(width, height)

        # global SCREEN_WIDTH
        # global SCREEN_HEIGHT

        # SCREEN_WIDTH, SCREEN_HEIGHT = width,height

        arcade.set_viewport(self.view_left, SCREEN_WIDTH + self.view_left,
                            self.view_bottom, SCREEN_HEIGHT + self.view_bottom)
Пример #10
0
obj1.create_coins(15, 20, 20)
obj1.create_coins(16, 75, 10)
obj1.create_coins(15, 75, 10)
obj1.create_coins(14, 70, 20)
obj1.create_coins(17, 70, 20)
obj1.create_coins(4, 167, 25)
obj1.create_coins(5, 167, 25)
obj1.create_coins(6, 167, 25)
obj1.create_coins(7, 167, 25)
# obj1.create_left_beam(7,250,19)
obj1.create_left_beam(7, 115, 19)
obj1.create_speedboost(12, 130)
mag_y = np.random.randint(5, 25)
mag_x = np.random.randint(5, 150)
obj1.create_attractivemag(mag_y, mag_x)
obj3 = Boss(10, 250, 3)
# obj3=Boss(10,75,3)
obj3.create_boss(obj1.grid)
a = np.random.randint(1, 100)
if a < 50:
    obj1.create_magnet(5, 85)
sttime = time.time()
xcoo = 26
ycoo = 1
boost = 0
down_speed = 0


def check_shield(passtime):
    if (obj2.available_shield == False):