コード例 #1
0
def GAME():
    # Game Variables
    ALL_SPRITES = pygame.sprite.Group()
    BULLETS_1 = pygame.sprite.Group()
    BULLETS_2 = pygame.sprite.Group()
    CLOCK = pygame.time.Clock()
    TEXTS1 = G.FONTSMALL.render('Player 1', True, D.PLAYER_DICT[G.P1CHAR.upper()]['COLOR'])
    TEXTS2 = G.FONTSMALL.render('Player 2', True, D.PLAYER_DICT[G.P2CHAR.upper()]['COLOR'])
    TEXTS3 = G.FONTSMALL.render('Escape to leave', True, G.WHITE)
    TEXTS4 = G.FONTSMALL.render('Enter to restart', True, G.WHITE)        
    # Using G.MODE, selects attributes to use for game
    GAME_MUSIC = D.MODE_DICT[G.MODE]['MUSIC']
    TIMER = D.MODE_DICT[G.MODE]['TIMER']
    PLAYER_VELOCITY = D.MODE_DICT[G.MODE]['PLAYER_VELOCITY']
    BULLET_VELOCITY = D.MODE_DICT[G.MODE]['BULLET_VELOCITY']
    PLAYER_1 = S.RECT((35, 35), BULLETS_2, (BULLET_VELOCITY, 0), G.P1CHAR, ALL_SPRITES)
    PLAYER_2 = S.RECT((465, 465), BULLETS_1, (-BULLET_VELOCITY, 0), G.P2CHAR, ALL_SPRITES)
    PLAYER_1.health = D.MODE_DICT[G.MODE]['HEALTH']
    PLAYER_2.health = D.MODE_DICT[G.MODE]['HEALTH']
    # DT is broken on classic so I added this :///
    if G.MODE == 'CLASSIC':
        DT_COOLDOWN = CLOCK.tick(60) / 1000
    else:
        DT_COOLDOWN = D.MODE_DICT[G.MODE]['DT']    
    # Bools
    LOOP = True
    TIME = True
    ABILITY_1 = False
    ABILITY_2 = False
    COOLDOWN_1 = 3
    COOLDOWN_2 = 3
    TIME_1 = True
    TIME_2 = True
    ON_START = True
    ON_END = False
    CONFIRM = False
    # Integers
    VELOCITY_RESET = 0
    DT = CLOCK.tick(60) / 1000
    TEXT_LOCAL = (222, 520)
    
    while LOOP:
        keys = pygame.key.get_pressed()
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                G.SUPERLOOP = False
                LOOP = False
            # Keymap
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_f and not PLAYER_1.toggle:
                    BULLET = S.BULLET(PLAYER_1.rect.center, (PLAYER_1.fire_direction), PLAYER_1.bullet_image, 'BULLET')
                    BULLETS_1.add(BULLET)
                    ALL_SPRITES.add(BULLET)
                    D.MEDIA['shoot_sound'].play()
                if event.key == pygame.K_SPACE and not PLAYER_2.toggle:
                    BULLET = S.BULLET(PLAYER_2.rect.center, (PLAYER_2.fire_direction), PLAYER_2.bullet_image, 'BULLET')
                    BULLETS_2.add(BULLET)
                    ALL_SPRITES.add(BULLET)
                    D.MEDIA['shoot_sound'].play()
                if event.key == pygame.K_e and not PLAYER_1.toggle and ABILITY_1:
                    PLAYER_1.ability(BULLETS_1, ALL_SPRITES, PLAYER_1.rect.center, (PLAYER_1.fire_direction), *PLAYER_1.params)
                    TIME_1 = True
                    ABILITY_1 = False
                    COOLDOWN_1 = 3
                if event.key == pygame.K_RCTRL and not PLAYER_2.toggle and ABILITY_2:
                    PLAYER_2.ability(BULLETS_2, ALL_SPRITES, PLAYER_2.rect.center, (PLAYER_2.fire_direction), *PLAYER_2.params)
                    TIME_2 = True
                    ABILITY_2 = False
                    COOLDOWN_2 = 3
                if event.key == pygame.K_d and not PLAYER_1.toggle and PLAYER_1.vel.x == 0:
                    PLAYER_1.vel.x = PLAYER_VELOCITY
                    PLAYER_1.fire_direction = (BULLET_VELOCITY, 0)
                if event.key == pygame.K_a and not PLAYER_1.toggle and PLAYER_1.vel.x == 0:
                    PLAYER_1.vel.x = -PLAYER_VELOCITY
                    PLAYER_1.fire_direction = (-BULLET_VELOCITY, 0)
                if event.key == pygame.K_s and not PLAYER_1.toggle and PLAYER_1.vel.y == 0:
                    PLAYER_1.vel.y = PLAYER_VELOCITY
                    PLAYER_1.fire_direction = (0, BULLET_VELOCITY)
                if event.key == pygame.K_w and not PLAYER_1.toggle and PLAYER_1.vel.y == 0:
                    PLAYER_1.vel.y = -PLAYER_VELOCITY
                    PLAYER_1.fire_direction = (0, -BULLET_VELOCITY)
                if event.key == pygame.K_RIGHT and not PLAYER_2.toggle and PLAYER_2.vel.x == 0:
                    PLAYER_2.vel.x = PLAYER_VELOCITY
                    PLAYER_2.fire_direction = (BULLET_VELOCITY, 0)
                if event.key == pygame.K_LEFT and not PLAYER_2.toggle and PLAYER_2.vel.x == 0:
                    PLAYER_2.vel.x = -PLAYER_VELOCITY
                    PLAYER_2.fire_direction = (-BULLET_VELOCITY, 0)                   
                if event.key == pygame.K_DOWN and not PLAYER_2.toggle and PLAYER_2.vel.y == 0:
                    PLAYER_2.vel.y = PLAYER_VELOCITY
                    PLAYER_2.fire_direction = (0, BULLET_VELOCITY)
                if event.key == pygame.K_UP and not PLAYER_2.toggle and PLAYER_2.vel.y == 0:
                    PLAYER_2.vel.y = -PLAYER_VELOCITY
                    PLAYER_2.fire_direction = (0, -BULLET_VELOCITY)
            if event.type == pygame.KEYUP:
                if event.key == pygame.K_d:
                    PLAYER_1.vel.x = VELOCITY_RESET
                if event.key == pygame.K_a:
                    PLAYER_1.vel.x = VELOCITY_RESET
                if event.key == pygame.K_s:
                    PLAYER_1.vel.y = VELOCITY_RESET
                if event.key == pygame.K_w:
                    PLAYER_1.vel.y = VELOCITY_RESET
                if event.key == pygame.K_RIGHT:
                    PLAYER_2.vel.x = VELOCITY_RESET
                if event.key == pygame.K_LEFT:
                    PLAYER_2.vel.x = VELOCITY_RESET
                if event.key == pygame.K_DOWN:
                    PLAYER_2.vel.y = VELOCITY_RESET
                if event.key == pygame.K_UP:
                    PLAYER_2.vel.y = VELOCITY_RESET
                    
        # Code that runs on first iteration, runs music and the "FIGHT!" announcer but only once
        if ON_START:
            D.MEDIA['fight_sound'].play()
            GAME_MUSIC.play()
            ON_START = False

        # On TAB keypress, all game functions cease and pause screen appears until LSHIFT/ESC/ENTER is pressed
        # ESC: Game leaves, both superloop and loop are declared false as the game ends
        # ENTER: Restarts, only loop ends, restarting the game
        # LSHIFT: Continues operation of game
        
        if keys[pygame.K_TAB] and not CONFIRM and not ON_END:
            CONFIRM = True
            TIME = False
            TIME_1 = False
            TIME_2 = False
            for SPRITE in ALL_SPRITES:
                SPRITE.toggle = True
            pygame.mixer.pause()
            D.MEDIA['pause_sound'].play()
            
        elif keys[pygame.K_LSHIFT] and CONFIRM:
            CONFIRM = False
            TIME = True
            TIME_1 = True
            TIME_2 = True
            for SPRITE in ALL_SPRITES:
                SPRITE.toggle = False
            pygame.mixer.unpause()
            D.MEDIA['pause_sound'].play()

        elif keys[pygame.K_ESCAPE] and CONFIRM:
            G.SUPERLOOP = False
            LOOP = False

        elif keys[pygame.K_RETURN] and CONFIRM:
            GAME_MUSIC.stop()
            LOOP = False

        # Time code, subtracts timer and cooldown, detects when time is @0 and does according actions, and contains more action code       
        if TIME:
            TIMER -= DT
            TXT = D.TIMER_DICT[TIMER < 10][1].render(str(round(TIMER, 1)), True, D.TIMER_DICT[TIMER < 10][0])
            if TIMER <= 0:
                for SPRITE in ALL_SPRITES:
                    SPRITE.toggle = True
                GAME_MUSIC.stop()
                TIME = False
                TIME_1 = False
                TIME_2 = False
                ON_END = True
                TEXT_LOCAL = (190, 530)
                TXT = G.FONTNORMAL.render('Times Up!', True, G.GREY)
                D.MEDIA['die_sound'].play()
                
        if not TIME and keys[pygame.K_ESCAPE]:
            G.SUPERLOOP = False
            LOOP = False         
        elif not TIME and keys[pygame.K_RETURN] and not CONFIRM:
            GAME_MUSIC.stop()
            LOOP = False
                    
        if TIME_1:
            COOLDOWN_1 -= DT_COOLDOWN
            if COOLDOWN_1 <= 0:
                TIME_1 = False
                ABILITY_1 = True         
        if TIME_2:
            COOLDOWN_2 -= DT_COOLDOWN
            if COOLDOWN_2 <= 0:
                TIME_2 = False
                ABILITY_2 = True
            
        # Outcome code, when health of a player(s) is at 0, code is run that shows outcome on timer area, stops time, and also contains key actions
        if PLAYER_1.health <= 0:
            TXT = G.FONTNORMAL.render('Player 2 Wins!', True, PLAYER_2.color)
            TEXT_LOCAL = (155, 530)
            TIME = False
            TIME_1 = False
            TIME_2 = False
            ON_END = True
            GAME_MUSIC.stop()
            if keys[pygame.K_ESCAPE] and not CONFIRM:
                G.SUPERLOOP = False
                LOOP = False
            elif keys[pygame.K_RETURN] and not CONFIRM:
                LOOP = False
                
        if PLAYER_2.health <= 0:
            TXT = G.FONTNORMAL.render('Player 1 Wins!', True, PLAYER_1.color)
            TEXT_LOCAL = (155, 530)
            TIME = False
            TIME_1 = False
            TIME_2 = False
            ON_END = True
            GAME_MUSIC.stop()
            if keys[pygame.K_ESCAPE] and not CONFIRM:
                G.SUPERLOOP = False
                LOOP = False
            elif keys[pygame.K_RETURN] and not CONFIRM:
                LOOP = False

        if PLAYER_1.health <= 0 and PLAYER_2.health <= 0:
            TXT = G.FONTNORMAL.render('Draw!', True, G.GREY)
            TEXT_LOCAL = (210, 530)
            TIME = False
            TIME_1 = False
            TIME_2 = False
            ON_END = True
            GAME_MUSIC.stop()
            if keys[pygame.K_ESCAPE] and not CONFIRM:
                G.SUPERLOOP = False
                LOOP = False
            elif keys[pygame.K_RETURN] and not CONFIRM:
                LOOP = False
            
        ALL_SPRITES.update()
        
        # Drawing code, draws media, hp bars, text, sprites, etc.
        # Cooldown drawing is still if statements as there is no convenient way to get instant draw code by using dictionaries

        G.SCREEN.fill(G.BLACK)
        G.SCREEN.blit(D.MEDIA['wall'], (0, 0))
        G.SCREEN.blit(pygame.transform.flip(D.HP_DICT[PLAYER_1.health], True, False), (20, 530))
        G.SCREEN.blit(D.HP_DICT[PLAYER_2.health], (380, 530))
        G.SCREEN.blit(TXT, TEXT_LOCAL)
        G.SCREEN.blit(TEXTS1, (19, 515))
        G.SCREEN.blit(TEXTS2, (429, 515))
        
        if COOLDOWN_1 <= 3 and COOLDOWN_1 >= 2:
            G.SCREEN.blit(D.MEDIA['cooldown4'], (100, 515))
        elif COOLDOWN_1 <= 2 and COOLDOWN_1 >= 1:
            G.SCREEN.blit(D.MEDIA['cooldown3'], (100, 515))
        elif COOLDOWN_1 <= 1 and COOLDOWN_1 >= 0:
            G.SCREEN.blit(D.MEDIA['cooldown2'], (100, 515))
        elif COOLDOWN_1 <= 0:
            G.SCREEN.blit(D.MEDIA['cooldown1'], (100, 515))
            
        if COOLDOWN_2 <= 3 and COOLDOWN_2 >= 2:
            G.SCREEN.blit(D.MEDIA['cooldown4'], (380, 515))
        elif COOLDOWN_2 <= 2 and COOLDOWN_2 >= 1:
            G.SCREEN.blit(D.MEDIA['cooldown3'], (380, 515))
        elif COOLDOWN_2 <= 1 and COOLDOWN_2 >= 0:
            G.SCREEN.blit(D.MEDIA['cooldown2'], (380, 515))
        elif COOLDOWN_2 <= 0:
            G.SCREEN.blit(D.MEDIA['cooldown1'], (380, 515))

        ALL_SPRITES.draw(G.SCREEN)
        
        if ON_END:
            G.SCREEN.blit(TEXTS3, (395, 10))
            G.SCREEN.blit(TEXTS4, (10, 10))
        if CONFIRM:
            G.SCREEN.blit(D.MEDIA['paused'], (154, 165))
                
        pygame.display.flip()
        CLOCK.tick(60)
コード例 #2
0
def GAME():
    # Game Variables
    ALL_SPRITES = pygame.sprite.Group()
    BULLETS1 = pygame.sprite.Group()
    BULLETS2 = pygame.sprite.Group()
    CLOCK = pygame.time.Clock()
    TEXTS1 = g.FONTSMALL.render('Player 1', True,
                                d.GAME_DICT[g.P1CHAR.upper()]['COLOR'])
    TEXTS2 = g.FONTSMALL.render('Player 2', True,
                                d.GAME_DICT[g.P2CHAR.upper()]['COLOR'])
    TEXTS3 = g.FONTSMALL.render('Escape to leave', True, g.WHITE)
    TEXTS4 = g.FONTSMALL.render('Enter to restart', True, g.WHITE)
    # Using the variable where mode is stored to set game conditions
    GAME_MUSIC = d.GAME_DICT['MODE'][g.MODE]['MUSIC']
    g.TIMER = d.GAME_DICT['MODE'][g.MODE]['TIMER']
    PLAYER_VELOCITY = d.GAME_DICT['MODE'][g.MODE]['PLAYER_VELOCITY']
    BULLET_VELOCITY = d.GAME_DICT['MODE'][g.MODE]['BULLET_VELOCITY']
    PLAYER1 = s.RECT((35, 35), BULLETS2, (BULLET_VELOCITY, 0), g.P1CHAR,
                     ALL_SPRITES)
    PLAYER2 = s.RECT((465, 465), BULLETS1, (-BULLET_VELOCITY, 0), g.P2CHAR,
                     ALL_SPRITES)
    PLAYER1.health = d.GAME_DICT['MODE'][g.MODE]['HEALTH']
    PLAYER2.health = d.GAME_DICT['MODE'][g.MODE]['HEALTH']
    DT_COOLDOWN = d.GAME_DICT['MODE'][g.MODE]['DT']
    # Bools
    LOOP = True
    TIME = True
    ABILITY1 = False
    ABILITY2 = False
    COOLDOWN1 = 3
    COOLDOWN2 = 3
    TIME1 = True
    TIME2 = True
    ON_START = True
    ON_END = True
    CONFIRM = False
    # Integers
    VELOCITY_RESET = 0
    DT = CLOCK.tick(60) / 1000
    TEXT_LOCAL = (222, 520)

    while LOOP:
        keys = pygame.key.get_pressed()
        # PARAMS [NEEDS TO BE REFRESHED
        ARGS_DICT = {
            'BLUE': {
                'PLAYER1': [
                    BULLETS1, ALL_SPRITES, PLAYER1.rect.center,
                    pygame.math.Vector2(PLAYER1.fire_direction),
                    m.MEDIA['blue_big_bullet']
                ],
                'PLAYER2': [
                    BULLETS2, ALL_SPRITES, PLAYER2.rect.center,
                    pygame.math.Vector2(PLAYER2.fire_direction),
                    m.MEDIA['blue_big_bullet']
                ]
            },
            'ORANGE': {
                'PLAYER1': [
                    BULLETS1, ALL_SPRITES, PLAYER1.rect.center,
                    pygame.math.Vector2(PLAYER1.fire_direction),
                    m.MEDIA['orange_big_bullet']
                ],
                'PLAYER2': [
                    BULLETS2, ALL_SPRITES, PLAYER2.rect.center,
                    pygame.math.Vector2(PLAYER2.fire_direction),
                    m.MEDIA['orange_big_bullet']
                ]
            },
            'GREEN': {
                'PLAYER1': [
                    BULLETS1, ALL_SPRITES, PLAYER1.rect.center,
                    pygame.math.Vector2(PLAYER1.fire_direction),
                    m.MEDIA['green_split_bullet'], 'GREEN'
                ],
                'PLAYER2': [
                    BULLETS2, ALL_SPRITES, PLAYER2.rect.center,
                    pygame.math.Vector2(PLAYER2.fire_direction),
                    m.MEDIA['green_split_bullet'], 'GREEN'
                ]
            },
            'PURPLE': {
                'PLAYER1': [
                    BULLETS1, ALL_SPRITES, PLAYER1.rect.center,
                    pygame.math.Vector2(PLAYER1.fire_direction), 'PURPLE'
                ],
                'PLAYER2': [
                    BULLETS2, ALL_SPRITES, PLAYER2.rect.center,
                    pygame.math.Vector2(PLAYER2.fire_direction), 'PURPLE'
                ]
            },
            'RED': {
                'PLAYER1': [
                    BULLETS1, ALL_SPRITES, PLAYER1.rect.center,
                    pygame.math.Vector2(PLAYER1.fire_direction), 'RED'
                ],
                'PLAYER2': [
                    BULLETS2, ALL_SPRITES, PLAYER2.rect.center,
                    pygame.math.Vector2(PLAYER2.fire_direction), 'RED'
                ]
            },
            'YELLOW': {
                'PLAYER1': [
                    BULLETS1, ALL_SPRITES, PLAYER1.rect.center,
                    pygame.math.Vector2(PLAYER1.fire_direction),
                    m.MEDIA['yellow_split_bullet'], 'YELLOW'
                ],
                'PLAYER2': [
                    BULLETS2, ALL_SPRITES, PLAYER2.rect.center,
                    pygame.math.Vector2(PLAYER2.fire_direction),
                    m.MEDIA['yellow_split_bullet'], 'YELLOW'
                ]
            },
            'GREY': {
                'PLAYER1': [
                    BULLETS1, ALL_SPRITES, PLAYER1.rect.center,
                    pygame.math.Vector2(PLAYER1.fire_direction),
                    m.MEDIA['grey_boomerang_bullet']
                ],
                'PLAYER2': [
                    BULLETS2, ALL_SPRITES, PLAYER2.rect.center,
                    pygame.math.Vector2(PLAYER2.fire_direction),
                    m.MEDIA['grey_boomerang_bullet']
                ]
            },
            'RAINBOW': {
                'PLAYER1': [BULLETS1, ALL_SPRITES, PLAYER1.rect.center],
                'PLAYER2': [BULLETS2, ALL_SPRITES, PLAYER2.rect.center]
            },
            'WHITE': {
                'PLAYER1': [
                    BULLETS1, ALL_SPRITES, PLAYER1.rect.center,
                    pygame.math.Vector2(PLAYER1.fire_direction),
                    m.MEDIA['white_boomerang_bullet']
                ],
                'PLAYER2': [
                    BULLETS2, ALL_SPRITES, PLAYER2.rect.center,
                    pygame.math.Vector2(PLAYER2.fire_direction),
                    m.MEDIA['white_boomerang_bullet']
                ]
            },
        }
        P1PARAMS = ARGS_DICT[g.P1CHAR.upper()]['PLAYER1']
        P2PARAMS = ARGS_DICT[g.P2CHAR.upper()]['PLAYER2']
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                g.SUPERLOOP = False
                LOOP = False
            # Keymap
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_f and not PLAYER1.toggle:
                    BULLET = s.BULLET(
                        PLAYER1.rect.center,
                        pygame.math.Vector2(PLAYER1.fire_direction),
                        PLAYER1.bullet_image)
                    BULLETS1.add(BULLET)
                    ALL_SPRITES.add(BULLET)
                    m.MEDIA['shoot_sound'].play()
                if event.key == pygame.K_SPACE and not PLAYER2.toggle:
                    BULLET = s.BULLET(
                        PLAYER2.rect.center,
                        pygame.math.Vector2(PLAYER2.fire_direction),
                        PLAYER2.bullet_image)
                    BULLETS2.add(BULLET)
                    ALL_SPRITES.add(BULLET)
                    m.MEDIA['shoot_sound'].play()
                if event.key == pygame.K_RCTRL and not PLAYER2.toggle and ABILITY2:
                    d.GAME_DICT[g.P2CHAR.upper()]['ABILITY'](*P2PARAMS)
                    COOLDOWN2 = 3
                    TIME2 = True
                    ABILITY2 = False
                if event.key == pygame.K_g and not PLAYER1.toggle and ABILITY1:
                    d.GAME_DICT[g.P1CHAR.upper()]['ABILITY'](*P1PARAMS)
                    COOLDOWN1 = 3
                    TIME1 = True
                    ABILITY1 = False
                if event.key == pygame.K_d and PLAYER1.toggle == False:
                    PLAYER1.vel.x = PLAYER_VELOCITY
                    PLAYER1.fire_direction = pygame.math.Vector2(
                        BULLET_VELOCITY, 0)
                if event.key == pygame.K_a and PLAYER1.toggle == False:
                    PLAYER1.vel.x = -PLAYER_VELOCITY
                    PLAYER1.fire_direction = pygame.math.Vector2(
                        -BULLET_VELOCITY, 0)
                if event.key == pygame.K_s and PLAYER1.toggle == False:
                    PLAYER1.vel.y = PLAYER_VELOCITY
                    PLAYER1.fire_direction = pygame.math.Vector2(
                        0, BULLET_VELOCITY)
                if event.key == pygame.K_w and PLAYER1.toggle == False:
                    PLAYER1.vel.y = -PLAYER_VELOCITY
                    PLAYER1.fire_direction = pygame.math.Vector2(
                        0, -BULLET_VELOCITY)
                if event.key == pygame.K_RIGHT and PLAYER2.toggle == False:
                    PLAYER2.vel.x = PLAYER_VELOCITY
                    PLAYER2.fire_direction = pygame.math.Vector2(
                        BULLET_VELOCITY, 0)
                if event.key == pygame.K_LEFT and PLAYER2.toggle == False:
                    PLAYER2.vel.x = -PLAYER_VELOCITY
                    PLAYER2.fire_direction = pygame.math.Vector2(
                        -BULLET_VELOCITY, 0)
                if event.key == pygame.K_DOWN and PLAYER2.toggle == False:
                    PLAYER2.vel.y = PLAYER_VELOCITY
                    PLAYER2.fire_direction = pygame.math.Vector2(
                        0, BULLET_VELOCITY)
                if event.key == pygame.K_UP and PLAYER2.toggle == False:
                    PLAYER2.vel.y = -PLAYER_VELOCITY
                    PLAYER2.fire_direction = pygame.math.Vector2(
                        0, -BULLET_VELOCITY)
            if event.type == pygame.KEYUP:
                if event.key == pygame.K_d:
                    PLAYER1.vel.x = VELOCITY_RESET
                if event.key == pygame.K_a:
                    PLAYER1.vel.x = VELOCITY_RESET
                if event.key == pygame.K_s:
                    PLAYER1.vel.y = VELOCITY_RESET
                if event.key == pygame.K_w:
                    PLAYER1.vel.y = VELOCITY_RESET
                if event.key == pygame.K_RIGHT:
                    PLAYER2.vel.x = VELOCITY_RESET
                if event.key == pygame.K_LEFT:
                    PLAYER2.vel.x = VELOCITY_RESET
                if event.key == pygame.K_DOWN:
                    PLAYER2.vel.y = VELOCITY_RESET
                if event.key == pygame.K_UP:
                    PLAYER2.vel.y = VELOCITY_RESET
        # Code that runs on first iteration
        if ON_START:
            m.MEDIA['fight_sound'].play()
            GAME_MUSIC.play()
            ON_START = False

        # Pause Function, stops all game movement
        if keys[pygame.K_TAB] and not CONFIRM and ON_END:
            PLAYER1.toggle = True
            PLAYER2.toggle = True
            CONFIRM = True
            TIME = False
            for BULLET in BULLETS1:
                BULLET.toggle = True
            for BULLET in BULLETS2:
                BULLET.toggle = True
            pygame.mixer.pause()
            m.MEDIA['pause_sound'].play()

        # Cancel Pause
        elif keys[pygame.K_LSHIFT] and CONFIRM:
            PLAYER1.toggle = False
            PLAYER2.toggle = False
            CONFIRM = False
            TIME = True
            for BULLET in BULLETS1:
                BULLET.toggle = False
            for BULLET in BULLETS2:
                BULLET.toggle = False
            pygame.mixer.unpause()
            m.MEDIA['pause_sound'].play()

        # Exit Game
        elif keys[pygame.K_ESCAPE] and CONFIRM:
            g.SUPERLOOP = False
            LOOP = False

        # Restarting Game
        elif keys[pygame.K_RETURN] and CONFIRM:
            GAME_MUSIC.stop()
            LOOP = False

        # Subtracting time, setting text, checking if timer has run out, more leaving/restart functions
        if TIME:
            g.TIMER -= DT
            TXT = d.GAME_DICT['TIMER'][g.TIMER < 10][1].render(
                str(round(g.TIMER, 1)), True,
                d.GAME_DICT['TIMER'][g.TIMER < 10][0])
            if g.TIMER <= 0:
                PLAYER1.toggle = True
                PLAYER2.toggle = True
                for BULLET in BULLETS1:
                    BULLET.toggle = True
                for BULLET in BULLETS2:
                    BULLET.toggle = True
                GAME_MUSIC.stop()
                TIME = False
                ON_END = False
                TEXT_LOCAL = (190, 530)
                TXT = g.FONTNORMAL.render('Times Up!', True, g.GREY)
                m.MEDIA['die_sound'].play()
            if not TIME and keys[pygame.K_ESCAPE]:
                pygame.quit()
                sys.exit()
            elif not TIME and keys[pygame.K_RETURN] and not CONFIRM:
                pygame.mixer.pause()
                LOOP = False

        # Subtracts cooldown/detects when cooldown is 0
        if TIME1:
            COOLDOWN1 -= DT_COOLDOWN
            if COOLDOWN1 <= 0:
                TIME1 = False
                ABILITY1 = True

        if TIME2:
            COOLDOWN2 -= DT_COOLDOWN
            if COOLDOWN2 <= 0:
                TIME2 = False
                ABILITY2 = True

        # Outcome is Player 2 Wins
        if PLAYER1.health <= 0:
            TXT = g.FONTNORMAL.render('Player 2 Wins!', True, PLAYER2.color)
            TEXT_LOCAL = (155, 530)
            TIME = False
            TIME1 = False
            TIME2 = False
            ON_END = False
            GAME_MUSIC.stop()
            if keys[pygame.K_ESCAPE] and not CONFIRM:
                g.SUPERLOOP = False
                LOOP = False
            elif keys[pygame.K_RETURN] and not CONFIRM:
                LOOP = False

        # Outcome if Player 1 Wins
        if PLAYER2.health <= 0:
            TXT = g.FONTNORMAL.render('Player 1 Wins!', True, PLAYER1.color)
            TEXT_LOCAL = (155, 530)
            TIME = False
            TIME1 = False
            TIME2 = False
            ON_END = False
            GAME_MUSIC.stop()
            if keys[pygame.K_ESCAPE] and not CONFIRM:
                g.SUPERLOOP = False
                LOOP = False
            elif keys[pygame.K_RETURN] and not CONFIRM:
                LOOP = False

        # Outcome of draw
        if PLAYER1.health <= 0 and PLAYER2.health <= 0:
            TXT = g.FONTNORMAL.render('Draw!', True, v.GREY)
            TEXT_LOCAL = (210, 530)
            TIME = False
            TIME1 = False
            TIME2 = False
            ON_END = False
            GAME_MUSIC.stop()
            if keys[pygame.K_ESCAPE] and not CONFIRM:
                g.SUPERLOOP = False
                LOOP = False
            elif keys[pygame.K_RETURN] and not CONFIRM:
                LOOP = False
        ALL_SPRITES.update()

        # Drawing Sprites/Bullets/GUI
        m.SCREEN.fill(g.BLACK)
        m.SCREEN.blit(m.MEDIA['wall'], (0, 0))
        m.SCREEN.blit(
            pygame.transform.flip(d.GAME_DICT['HP'][PLAYER1.health], True,
                                  False), (20, 530))
        m.SCREEN.blit(d.GAME_DICT['HP'][PLAYER2.health], (380, 530))
        m.SCREEN.blit(TXT, TEXT_LOCAL)
        m.SCREEN.blit(TEXTS1, (19, 515))
        m.SCREEN.blit(TEXTS2, (429, 515))
        # Cooldown blitting [Probaly Will Optimize with GAME_DICT]
        if COOLDOWN1 <= 3 and COOLDOWN1 >= 2:
            m.SCREEN.blit(m.MEDIA['cooldown3'], (100, 515))
        elif COOLDOWN1 <= 2 and COOLDOWN1 >= 1:
            m.SCREEN.blit(m.MEDIA['cooldown2'], (100, 515))
        elif COOLDOWN1 <= 1 and COOLDOWN1 >= 0:
            m.SCREEN.blit(m.MEDIA['cooldown1'], (100, 515))
        elif COOLDOWN1 <= 0:
            m.SCREEN.blit(m.MEDIA['cooldown0'], (100, 515))

        if COOLDOWN2 <= 3 and COOLDOWN2 >= 2:
            m.SCREEN.blit(m.MEDIA['cooldown3'], (380, 515))
        elif COOLDOWN2 <= 2 and COOLDOWN2 >= 1:
            m.SCREEN.blit(m.MEDIA['cooldown2'], (380, 515))
        elif COOLDOWN2 <= 1 and COOLDOWN2 >= 0:
            m.SCREEN.blit(m.MEDIA['cooldown1'], (380, 515))
        elif COOLDOWN2 <= 0:
            m.SCREEN.blit(m.MEDIA['cooldown0'], (380, 515))
        ALL_SPRITES.draw(m.SCREEN)
        if not ON_END:
            m.SCREEN.blit(TEXTS3, (395, 10))
            m.SCREEN.blit(TEXTS4, (10, 10))
        if CONFIRM:
            m.SCREEN.blit(m.MEDIA['paused'], (154, 165))

        pygame.display.flip()
        CLOCK.tick(60)