示例#1
0
def MODE_SELECT():
    CLOCK = pygame.time.Clock()
    LOOP = True
    ALL_SPRITES = pygame.sprite.Group()
    SELECTOR_BIG = S.SELECTOR_BIG((250, 200))
    ALL_SPRITES.add(SELECTOR_BIG)
    SELECTINT = 0
    MODE_CHOICES = ['CLASSIC', 'TENSE', 'CHAOS']
    TEXTS1 = G.FONTNORMAL.render('Choose your difficulty', True, G.WHITE)
    TEXTS2 = G.FONTNORMAL.render('Space to continue', True, G.WHITE)    

    while LOOP:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
            # Keymap
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_UP:
                    SELECTINT -= 1
                    SELECTOR_BIG.pos[1] -= 100

                    
                if event.key == pygame.K_DOWN:
                    SELECTINT += 1
                    SELECTOR_BIG.pos[1] += 100
                    
                if event.key == pygame.K_SPACE:
                    '''Loads values into G.MODE'''
                    G.MODE = MODE_CHOICES[SELECTINT]
                    D.MODE_DICT[G.MODE]['SOUND'].play()
                    LOOP = False
                    
                if event.key in (pygame.K_UP, pygame.K_DOWN):
                    if SELECTINT  == -1:
                        SELECTINT = 2
                    elif SELECTINT == 3:
                        SELECTINT = 0
                    D.MEDIA['select_sound'].play()
        ALL_SPRITES.update()

        # Drawing
        G.SCREEN.fill(G.BLACK)
        G.SCREEN.blit(D.MEDIA['classic_card'], (150, 150))
        G.SCREEN.blit(D.MEDIA['tense_card'], (150, 250))
        G.SCREEN.blit(D.MEDIA['chaos_card'], (150, 350))
        ALL_SPRITES.draw(G.SCREEN)
        # G.SCREEN.blit(D.MEDIA['mode_select_border'], (0, 0))
        G.SCREEN.blit(TEXTS1, (100, 50))
        G.SCREEN.blit(TEXTS2, (125, 500))

        pygame.display.flip()
        CLOCK.tick(60)
示例#2
0
def RED_LASER_BEAM(groupa, groupb, pos, vel):
    if vel[0] == 8 and vel[1] == 0:
        vel = (vel[0] - 3, vel[1])
    elif vel[0] == -8 and vel[1] == 0:
        vel = (vel[0] + 3, vel[1])
    elif vel[0] == 0 and vel[1] == 8:
        vel = (vel[0], vel[1] - 3)
    elif vel[0] == 0 and vel[1] == -8:
        vel = (vel[0], vel[1] + 3)
    BEAM = s.RedBeam(pos, vel)
    groupa.add(BEAM)
    groupb.add(BEAM)
示例#3
0
def MULTI_BULLET(groupa, groupb, pos):
    BULLET1 = s.Bullet(pos, (6, 0), m.MEDIA['red_bullet'])
    BULLET2 = s.Bullet(pos, (6, -6), m.MEDIA['orange_bullet'])
    BULLET3 = s.Bullet(pos, (0, -6), m.MEDIA['yellow_bullet'])
    BULLET4 = s.Bullet(pos, (-6, -6), m.MEDIA['green_bullet'])
    BULLET5 = s.Bullet(pos, (-6, 0), m.MEDIA['blue_bullet'])
    BULLET6 = s.Bullet(pos, (-6, 6), m.MEDIA['purple_bullet'])
    BULLET7 = s.Bullet(pos, (0, 6), m.MEDIA['white_bullet'])
    BULLET8 = s.Bullet(pos, (6, 6), m.MEDIA['grey_bullet'])
    groupa.add(BULLET1, BULLET2, BULLET3, BULLET4, BULLET5, BULLET6, BULLET7,
               BULLET8)
    groupb.add(BULLET1, BULLET2, BULLET3, BULLET4, BULLET5, BULLET6, BULLET7,
               BULLET8)
    m.MEDIA['multi_shoot_sound'].play()
示例#4
0
def MULTI_BULLET(GROUP_A, GROUP_B, POS):
    BULLET_1 = s.BULLET(POS, (6, 0), m.MEDIA['red_bullet'])
    BULLET_2 = s.BULLET(POS, (6, -6), m.MEDIA['orange_bullet'])
    BULLET_3 = s.BULLET(POS, (0, -6), m.MEDIA['yellow_bullet'])
    BULLET_4 = s.BULLET(POS, (-6, -6), m.MEDIA['green_bullet'])
    BULLET_5 = s.BULLET(POS, (-6, 0), m.MEDIA['blue_bullet'])
    BULLET_6 = s.BULLET(POS, (-6, 6), m.MEDIA['purple_bullet'])
    BULLET_7 = s.BULLET(POS, (0, 6), m.MEDIA['white_bullet'])
    BULLET_8 = s.BULLET(POS, (6, 6), m.MEDIA['grey_bullet'])
    groupa.add(BULLET_1, BULLET_2, BULLET_3, BULLET_4, BULLET_5, BULLET_6,
               BULLET_7, BULLET_8)
    groupb.add(BULLET_1, BULLET_2, BULLET_3, BULLET_4, BULLET_5, BULLET_6,
               BULLET_7, BULLET_8)
    m.MEDIA['multi_shoot_sound'].play()
示例#5
0
def BIG_BULLET(GROUP_A, GROUP_B, POS, VEL, IMG):
    if VEL[0] == 8 and VEL[1] == 0:
        VEL = (VEL[0] - 4, 0)
    elif VEL[0] == -8 and VEL[1] == 0:
        VEL = (VEL[0] + 4, 0)
    elif VEL[0] == 0 and VEL[1] == 8:
        VEL = (0, VEL[1] - 4)
    elif VEL[0] == 0 and VEL[1] == -8:
        VEL = (0, VEL[1] + 4)
    BIGBULLET = s.BIG_BULLET(POS, VEL, IMG)
    GROUP_A.add(BIGBULLET)
    GROUP_B.add(BIGBULLET)
    m.MEDIA['big_shoot_sound'].play()
示例#6
0
 def __init__(self, pos, sprite, item_type, effect):
     '''Item that can be picked up by the player\npos -> tile pos | sprite -> texture path | item_type -> health, armor, *ammo*, gun\neffect -> relative'''
     self.pos = (pos[0] * SETTINGS.tile_size, pos[1] * SETTINGS.tile_size)
     self.map_pos = pos
     self.item_type = item_type
     self.rect = pygame.Rect(self.pos[0], self.pos[1],
                             int(SETTINGS.tile_size / 2),
                             int(SETTINGS.tile_size / 2))
     self.rect.center = (self.pos[0] + SETTINGS.tile_size / 2,
                         self.pos[1] + SETTINGS.tile_size / 2)
     self.sprite = SPRITES.Sprite(pygame.image.load(sprite),
                                  hash(item_type), self.rect.center,
                                  'sprite')
     self.effect = effect
示例#7
0
def BIG_BULLET(groupa, groupb, pos, vel, img):
    if not vel[0] == 0:
        if not vel[0] == -8:
            vel = (vel[0] - 4, 0)
        else:
            vel = (vel[0] + 4, 0)
    if not vel[1] == 0 and vel[0] == 0:
        if not vel[1] == -8:
            vel = (0, vel[1] - 4)
        else:
            vel = (0, vel[1] + 4)
    BIGBULLET = s.BigBullet(pos, vel, img)
    groupa.add(BIGBULLET)
    groupb.add(BIGBULLET)
    m.MEDIA['big_shoot_sound'].play()
示例#8
0
def MODE_SELECT():
    CLOCK = pygame.time.Clock()
    LOOP = True
    ALL_SPRITES = pygame.sprite.Group()
    SELECTOR_BIG = s.SelectorBig((250, 250))
    MODE_CHOICES = ['CLASSIC', 'CHAOS']
    ALL_SPRITES.add(SELECTOR_BIG)
    TEXTS1 = g.FONTNORMAL.render('Choose Mode', True, g.WHITE)
    TEXTS2 = g.FONTNORMAL.render('Space To Continue', True, g.WHITE)
    SELECTOR = 0

    while LOOP:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
            # Keymap
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_UP:
                    SELECTOR += 1
                    SELECTOR_BIG.pos[1] -= 100
                if event.key == pygame.K_DOWN:
                    SELECTOR -= 1
                    SELECTOR_BIG.pos[1] += 100
                if event.key == pygame.K_SPACE:
                    # Load Mode into variable to use later
                    g.MODE = MODE_CHOICES[SELECTOR]
                    d.GAME_DICT['MODE'][g.MODE]['SOUND'].play()
                    LOOP = False
                if event.key in (pygame.K_UP, pygame.K_DOWN):
                    SELECTOR %= len(MODE_CHOICES)
                    g.MODE = MODE_CHOICES[SELECTOR]
                    m.MEDIA['select_sound'].play()
        ALL_SPRITES.update()

        # Drawing
        m.SCREEN.fill(g.BLACK)
        m.SCREEN.blit(m.MEDIA['classic_card'], (150, 200))
        m.SCREEN.blit(m.MEDIA['chaos_card'], (150, 300))
        m.SCREEN.blit(TEXTS1, (155, 100))
        m.SCREEN.blit(TEXTS2, (120, 500))
        ALL_SPRITES.draw(m.SCREEN)

        pygame.display.flip()
        CLOCK.tick(60)
示例#9
0
def MODE_SELECT():
    CLOCK = pygame.time.Clock()
    LOOP = True
    ALL_SPRITES = pygame.sprite.Group()
    SELECTOR_BIG = S.SELECTOR_BIG((250, 250))
    MODE_CHOICES = ['CLASSIC', 'CHAOS']
    ALL_SPRITES.add(SELECTOR_BIG)
    SELECTINT = 0

    while LOOP:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
            # Keymap
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_UP:
                    SELECTINT += 1
                    SELECTOR_BIG.pos[1] -= 100
                if event.key == pygame.K_DOWN:
                    SELECTINT -= 1
                    SELECTOR_BIG.pos[1] += 100
                if event.key == pygame.K_SPACE:
                    '''Loads values into G.MODE'''
                    G.MODE = MODE_CHOICES[SELECTINT]
                    D.MODE_DICT[G.MODE]['SOUND'].play()
                    LOOP = False
                if event.key in (pygame.K_UP, pygame.K_DOWN):
                    SELECTINT %= len(MODE_CHOICES)
                    G.MODE = MODE_CHOICES[SELECTINT]
                    D.MEDIA['select_sound'].play()
        ALL_SPRITES.update()

        # Drawing
        G.SCREEN.fill(G.BLACK)
        G.SCREEN.blit(D.MEDIA['classic_card'], (150, 200))
        G.SCREEN.blit(D.MEDIA['chaos_card'], (150, 300))
        ALL_SPRITES.draw(G.SCREEN)
        G.SCREEN.blit(D.MEDIA['mode_select_border'], (0, 0))

        pygame.display.flip()
        CLOCK.tick(60)
示例#10
0
    def __init__(self, ID, pos, map_pos):
        self.ID = ID
        #position in pixels
        self.pos = pos
        self.type = SETTINGS.texture_type[self.ID]
        #position in tiles
        self.map_pos = map_pos
        self.distance = None
        self.solid = SETTINGS.tile_solid[self.ID]
        #For doors opening
        self.state = None
        self.timer = 0

        if self.type == 'sprite':
            current_number = len(SETTINGS.all_sprites)
            #Need some weird coordinates to make it centered.
            self.texture = SPRITES.Sprite(
                SETTINGS.tile_texture[self.ID], self.ID,
                (self.pos[0] + SETTINGS.tile_size / 3,
                 self.pos[1] + SETTINGS.tile_size / 3), 'sprite')

            self.rect = pygame.Rect(pos[0], pos[1], SETTINGS.tile_size,
                                    SETTINGS.tile_size)

        else:
            self.texture = SETTINGS.tile_texture[self.ID].texture
            self.texture = pygame.transform.scale(
                self.texture,
                (SETTINGS.tile_size, SETTINGS.tile_size)).convert()
            self.rect = self.texture.get_rect()
            self.rect.x = pos[0]
            self.rect.y = pos[1]

            if self.type == 'vdoor' or self.type == 'hdoor':
                self.open = 0
                self.state = 'closed'
                #states: closed, opening, open, closing

                SETTINGS.all_doors.append(self)
示例#11
0
def SPLIT_BULLET(GROUP_A, GROUP_B, POS, VEL, IMG, COLOR):
    SPLIT_BULLET = s.SPLIT_BULLET(POS, VEL, IMG, GROUP_A, GROUP_B, COLOR)
    GROUP_A.add(SPLIT_BULLET)
    GROUP_B.add(SPLIT_BULLET)
    m.MEDIA['split_shoot_sound'].play()
示例#12
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.Player((35, 35), BULLETS2, (BULLET_VELOCITY, 0), g.P1CHAR,
                       ALL_SPRITES)
    PLAYER2 = s.Player((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']
    # Bools
    LOOP = True
    TIME = True
    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:
        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_e 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_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
        keys = pygame.key.get_pressed()
        # 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)
            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

        # 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
            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 = (210, 530)
            TIME = 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
            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))
        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)
示例#13
0
def CHARACTER_SELECT():
    def GET(INSERT):
        IMAGE = d.GAME_DICT[INSERT.upper()]['PLAYER_IMAGE']
        COLOR = d.GAME_DICT[INSERT.upper()]['COLOR']
        TEXT = g.FONTNORMAL.render(INSERT, True, COLOR)
        return IMAGE, TEXT

    COLOR_CHOICES = [
        'Blue', 'Orange', 'Green', 'Purple', 'Red', 'Yellow', 'Grey', 'White',
        'Rainbow'
    ]
    PLAYER1 = 0
    PLAYER2 = 1
    TEXTS1 = g.FONTNORMAL.render('Choose Your Character', True, g.WHITE)
    TEXTS2 = g.FONTNORMAL.render('Space To Continue', True, g.WHITE)
    TEXTS3 = g.FONTIB.render('VS.', True, g.WHITE)
    ALL_SPRITES = pygame.sprite.Group()
    PLAYER1_IMAGE, TEXT1 = GET(COLOR_CHOICES[PLAYER1])
    PLAYER2_IMAGE, TEXT2 = GET(COLOR_CHOICES[PLAYER2])
    SELECTORA = s.Selector((30, 188))
    SELECTORB = s.Selector((85, 388))
    ALL_SPRITES.add(SELECTORA, SELECTORB)
    CLOCK = pygame.time.Clock()
    LOOP = True

    while LOOP:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
                # Keymap
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_d:
                    PLAYER1 += 1
                    SELECTORA.pos[0] += 55
                elif event.key == pygame.K_a:
                    PLAYER1 -= 1
                    SELECTORA.pos[0] -= 55
                if event.key == pygame.K_RIGHT:
                    PLAYER2 += 1
                    SELECTORB.pos[0] += 55
                elif event.key == pygame.K_LEFT:
                    PLAYER2 -= 1
                    SELECTORB.pos[0] -= 55
                if event.key == pygame.K_SPACE:
                    # Load Character choice into variable to use later
                    g.P1CHAR = COLOR_CHOICES[PLAYER1]
                    g.P2CHAR = COLOR_CHOICES[PLAYER2]
                    LOOP = False
                if event.key in (pygame.K_d, pygame.K_a, pygame.K_RIGHT,
                                 pygame.K_LEFT):
                    PLAYER1 %= len(COLOR_CHOICES)
                    PLAYER2 %= len(COLOR_CHOICES)
                    PLAYER1_IMAGE, TEXT1 = GET(COLOR_CHOICES[PLAYER1])
                    PLAYER2_IMAGE, TEXT2 = GET(COLOR_CHOICES[PLAYER2])
                    m.MEDIA['select_sound'].play()
        ALL_SPRITES.update()

        # Drawing GUI
        m.SCREEN.fill(g.BLACK)
        m.SCREEN.blit(TEXTS1, (90, 50))
        m.SCREEN.blit(TEXTS2, (120, 500))
        m.SCREEN.blit(TEXTS3, (230, 275))
        m.SCREEN.blit(
            TEXT1, (d.GAME_DICT[COLOR_CHOICES[PLAYER1].upper()]['LOCAL'], 218))
        m.SCREEN.blit(
            TEXT2, (d.GAME_DICT[COLOR_CHOICES[PLAYER2].upper()]['LOCAL'], 330))

        m.SCREEN.blit(m.MEDIA['blue_face'], (5, 163))
        m.SCREEN.blit(m.MEDIA['orange_face'], (60, 163))
        m.SCREEN.blit(m.MEDIA['green_face'], (115, 163))
        m.SCREEN.blit(m.MEDIA['purple_face'], (170, 163))
        m.SCREEN.blit(m.MEDIA['red_face'], (225, 163))
        m.SCREEN.blit(m.MEDIA['yellow_face'], (280, 163))
        m.SCREEN.blit(m.MEDIA['grey_face'], (335, 163))
        m.SCREEN.blit(m.MEDIA['white_face'], (390, 163))
        m.SCREEN.blit(m.MEDIA['rainbow_face'], (445, 163))

        m.SCREEN.blit(m.MEDIA['blue_face'], (60 - 55, 363))
        m.SCREEN.blit(m.MEDIA['orange_face'], (115 - 55, 363))
        m.SCREEN.blit(m.MEDIA['green_face'], (170 - 55, 363))
        m.SCREEN.blit(m.MEDIA['purple_face'], (225 - 55, 363))
        m.SCREEN.blit(m.MEDIA['red_face'], (280 - 55, 363))
        m.SCREEN.blit(m.MEDIA['yellow_face'], (335 - 55, 363))
        m.SCREEN.blit(m.MEDIA['grey_face'], (390 - 55, 363))
        m.SCREEN.blit(m.MEDIA['white_face'], (390, 363))
        m.SCREEN.blit(m.MEDIA['rainbow_face'], (445, 363))

        ALL_SPRITES.draw(m.SCREEN)

        pygame.display.flip()
        CLOCK.tick(60)
示例#14
0
def SPLIT_BULLET(groupa, groupb, pos, vel, img, color):
    SPLIT_BULLET = s.SplitBullet(pos, vel, img, groupa, groupb, color)
    groupa.add(SPLIT_BULLET)
    groupb.add(SPLIT_BULLET)
示例#15
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)
示例#16
0
def TEMP_DEFAULT(groupa, groupb, pos, vel, img):
    BULLET = s.Bullet(pos, vel, img)
    groupa.add(BULLET)
    groupb.add(BULLET)
    m.MEDIA['shoot_sound'].play()
示例#17
0
    def __init__(self, stats, sounds, texture):
        #Technical settings
        self.uid = id(self)
        self.stats = stats #Used for creating new NPCs
        self.sounds = sounds
        self.ID = stats['id']
        self.map_pos = stats['pos']
        self.OG_map_pos = stats['pos']
        self.pos = [self.map_pos[0]*SETTINGS.tile_size, self.map_pos[1]*SETTINGS.tile_size]
        self.face = stats['face']
        self.frame_interval = stats['spf']

        #Visual and rect settings
        self.rect = pygame.Rect((self.pos[0], self.pos[1]), (SETTINGS.tile_size/3, SETTINGS.tile_size/3))
        self.rect.center = (self.pos[0] + SETTINGS.tile_size/2, self.pos[1] + SETTINGS.tile_size/2)
        self.real_x = self.rect.x
        self.real_y = self.rect.y

        #Initialise boring variables
        self.timer = 0
        self.idle_timer = 0
        self.alive_turn = 0 # make this number of "turns" rather than absolute timer
        self.die_animation = False
        self.running_animation = None
        self.add = 0
        self.dist_from_player = None
        self.dist = None
        self.collide_list = SETTINGS.all_solid_tiles + SETTINGS.npc_list
        self.solid = True
        self.side = None
        self.in_canvas = False
        self.path = []
        self.path_progress = 0
        self.attack_move = False
        self.atckchance = 5
        self.movechance = 10
        self.knockback = 0
        self.postheta = 0
        self.mein_leben = False
        self.type = 'npc'
        self.last_seen_player_turn = None
        self.last_seen_player_position = None
        # debug maybe later messaging system?
        self.messages = []

        # NPC Characteristics
        self.health = stats['health']
        self.speed = stats['speed']
        self.OG_speed = self.speed
        self.mind = stats['mind']
        self.state = stats['state']
        self.OG_state = self.state
        self.atcktype = stats['atcktype']
        self.name = stats['name']
        self.perception_range = int(SETTINGS.tile_size * random.choice([1, 1, 1, 1, 2, 2, 2, 3, 3, 4])) + SETTINGS.tile_size
        self.OG_perception_range = self.perception_range
        self.max_perception_range = int((SETTINGS.render * 0.8) * SETTINGS.tile_size)
        self.call_for_help_turns = 40 * random.choice(list(range(1, 4)))
        self.search_turns = (self.call_for_help_turns * random.choice([3, 3, 3, 4, 4, 5]))

        if stats['dmg'] != 3.1415:
            self.dmg = stats['dmg']
        else:
            self.dmg = random.choice([1,2,3])
        self.atckrate = stats['atckrate']

        self.range = 5

        #make first level easier
        if SETTINGS.current_level == 0 and SETTINGS.levels_list == SETTINGS.glevels_list:
            self.health = int(self.health * 0.8)
            self.dmg = int(self.dmg * 0.8)
            
        #Make late levels harder >:)
        elif SETTINGS.current_level > 4 and SETTINGS.levels_list == SETTINGS.glevels_list:
            self.health += int(SETTINGS.current_level / 3)
            self.dmg += int(SETTINGS.current_level / 5)

        #Make NPC stronger if player is doing well
        if SETTINGS.player_health >= 90 or SETTINGS.player_armor >= 90:
            self.dmg += 2

        #Give NPC more health if player has lots of ammo - phew, long line.
        if SETTINGS.inventory['primary'] and SETTINGS.held_ammo[SETTINGS.inventory['primary'].ammo_type] >= SETTINGS.max_ammo[SETTINGS.inventory['primary'].ammo_type]:
            self.health = int(self.health * 1.5)

        #Npc actions
        self.dead = False
        self.moving = False
        self.attacking = False
        self.hurting = False
        self.player_in_view = False

        #Textures and animations
        self.texture_path = texture # Used for creating new NPCS
        self.texture = pygame.image.load(texture).convert_alpha()
        self.texturerect = self.texture.get_rect()
        
        self.stand_texture = [self.texture.subsurface(0,0,64,128).convert_alpha(), self.texture.subsurface(64,0,64,128).convert_alpha(), self.texture.subsurface(128,0,64,128).convert_alpha(), self.texture.subsurface(192,0,64,128).convert_alpha(), self.texture.subsurface(256,0,64,128).convert_alpha(), self.texture.subsurface(320,0,64,128).convert_alpha(), self.texture.subsurface(384,0,64,128).convert_alpha(), self.texture.subsurface(448,0,64,128).convert_alpha()]
        self.front_texture = [self.texture.subsurface(0,128,64,128).convert_alpha(), self.texture.subsurface(64,128,64,128).convert_alpha(), self.texture.subsurface(128,128,64,128).convert_alpha(), self.texture.subsurface(192,128,64,128).convert_alpha(), self.texture.subsurface(256,128,64,128).convert_alpha(), self.texture.subsurface(320,128,64,128).convert_alpha(), self.texture.subsurface(384,128,64,128).convert_alpha(), self.texture.subsurface(448,128,64,128).convert_alpha(), self.texture.subsurface(512,128,64,128).convert_alpha(), self.texture.subsurface(576,128,64,128).convert_alpha()]
        self.frontright_texture = [self.texture.subsurface(0,256,64,128).convert_alpha(), self.texture.subsurface(64,256,64,128).convert_alpha(), self.texture.subsurface(128,256,64,128).convert_alpha(), self.texture.subsurface(192,256,64,128).convert_alpha(), self.texture.subsurface(256,256,64,128).convert_alpha(), self.texture.subsurface(320,256,64,128).convert_alpha(), self.texture.subsurface(384,256,64,128).convert_alpha(), self.texture.subsurface(448,256,64,128).convert_alpha(), self.texture.subsurface(512,256,64,128).convert_alpha(), self.texture.subsurface(576,256,64,128).convert_alpha()]
        self.right_texture = [self.texture.subsurface(0,384,64,128).convert_alpha(), self.texture.subsurface(64,384,64,128).convert_alpha(), self.texture.subsurface(128,384,64,128).convert_alpha(), self.texture.subsurface(192,384,64,128).convert_alpha(), self.texture.subsurface(256,384,64,128).convert_alpha(), self.texture.subsurface(320,384,64,128).convert_alpha(), self.texture.subsurface(384,384,64,128).convert_alpha(), self.texture.subsurface(448,384,64,128).convert_alpha(), self.texture.subsurface(512,384,64,128).convert_alpha(), self.texture.subsurface(576,384,64,128).convert_alpha()]
        self.backright_texture = [self.texture.subsurface(0,512,64,128).convert_alpha(), self.texture.subsurface(64,512,64,128).convert_alpha(), self.texture.subsurface(128,512,64,128).convert_alpha(), self.texture.subsurface(192,512,64,128).convert_alpha(), self.texture.subsurface(256,512,64,128).convert_alpha(), self.texture.subsurface(320,512,64,128).convert_alpha(), self.texture.subsurface(384,512,64,128).convert_alpha(), self.texture.subsurface(448,512,64,128).convert_alpha(), self.texture.subsurface(512,512,64,128).convert_alpha(), self.texture.subsurface(576,512,64,128).convert_alpha()]
        self.back_texture = [self.texture.subsurface(0,640,64,128).convert_alpha(), self.texture.subsurface(64,640,64,128).convert_alpha(), self.texture.subsurface(128,640,64,128).convert_alpha(), self.texture.subsurface(192,640,64,128).convert_alpha(), self.texture.subsurface(256,640,64,128).convert_alpha(), self.texture.subsurface(320,640,64,128).convert_alpha(), self.texture.subsurface(384,640,64,128).convert_alpha(), self.texture.subsurface(448,640,64,128).convert_alpha(), self.texture.subsurface(512,640,64,128).convert_alpha(), self.texture.subsurface(576,640,64,128).convert_alpha()]
        
        self.backleft_texture = []
        self.left_texture = []
        self.frontleft_texture = []

        for frame in self.backright_texture:
            self.backleft_texture.append(pygame.transform.flip(frame, True, False))
        for frame in self.right_texture:
            self.left_texture.append(pygame.transform.flip(frame, True, False))
        for frame in self.frontright_texture:
            self.frontleft_texture.append(pygame.transform.flip(frame, True, False))

        self.die_texture = [self.texture.subsurface(0,768,64,128).convert_alpha(), self.texture.subsurface(64,768,64,128).convert_alpha(), self.texture.subsurface(128,768,64,128).convert_alpha(), self.texture.subsurface(192,768,64,128).convert_alpha(), self.texture.subsurface(256,768,64,128).convert_alpha(), self.texture.subsurface(320,768,64,128).convert_alpha(), self.texture.subsurface(384,768,64,128).convert_alpha(), self.texture.subsurface(448,768,64,128).convert_alpha(), self.texture.subsurface(512,768,64,128).convert_alpha(), self.texture.subsurface(576,768,64,128).convert_alpha(), self.texture.subsurface(640,768,64,128).convert_alpha()]
        self.hit_texture = [self.texture.subsurface(0,896,64,128).convert_alpha(), self.texture.subsurface(64,896,64,128).convert_alpha(), self.texture.subsurface(128,896,64,128).convert_alpha(), self.texture.subsurface(192,896,64,128).convert_alpha(), self.texture.subsurface(256,896,64,128).convert_alpha(), self.texture.subsurface(320,896,64,128).convert_alpha()]
        self.hurt_texture = [self.die_texture[0]]
        self.update_timer = 0

        #Creating the sprite rect is awful, I know. Keeps it from entering walls.
        self.sprite = SPRITES.Sprite(self.front_texture[1], self.ID, [self.rect.centerx - int(SETTINGS.tile_size / 12), self.rect.centery - int(SETTINGS.tile_size / 10)], 'npc', self)

        #The position in SETTINGS.all_sprites of this NPC
        self.num = len(SETTINGS.all_sprites)-1
示例#18
0
def REVERSE_BULLET(GROUP_A, GROUP_B, POS, VEL, IMG):
    REVERSE_BULLET = s.REVERSE_BULLET(POS, VEL, IMG)
    GROUP_A.add(REVERSE_BULLET)
    GROUP_B.add(REVERSE_BULLET)
    m.MEDIA['reverse_shoot_sound'].play()
示例#19
0
def LASER_BEAM(GROUP_A, GROUP_B, POS, VEL, COLOR):
    BEAM = s.BEAM(POS, VEL, COLOR)
    GROUP_A.add(BEAM)
    GROUP_B.add(BEAM)
    m.MEDIA['laser_shoot_sound'].play()
示例#20
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)
示例#21
0
文件: NPC.py 项目: Hoboneer/DUGA
    def __init__(self, stats, sounds, texture):
        #Technical settings
        self.stats = stats #Used for creating new NPCs
        self.sounds = sounds
        self.ID = stats['id']
        self.map_pos = stats['pos']
        self.pos = [self.map_pos[0]*SETTINGS.tile_size, self.map_pos[1]*SETTINGS.tile_size]
        self.face = stats['face']
        self.frame_interval = stats['spf']

        #Visual and rect settings
        self.rect = pygame.Rect((self.pos[0], self.pos[1]), (SETTINGS.tile_size/3, SETTINGS.tile_size/3))
        self.rect.center = (self.pos[0] + SETTINGS.tile_size/2, self.pos[1] + SETTINGS.tile_size/2)
        self.real_x = self.rect.x
        self.real_y = self.rect.y

        #Initialise boring variables
        self.timer = 0
        self.idle_timer = 0
        self.die_animation = False
        self.running_animation = None
        self.add = 0
        self.dist = None
        self.collide_list = SETTINGS.all_solid_tiles + SETTINGS.npc_list
        self.solid = True
        self.side = None
        self.in_canvas = False
        self.path = []
        self.path_progress = 0
        self.attack_move = False
        self.atckchance = 5
        self.movechance = 10
        self.knockback = 0
        self.postheta = 0
        self.mein_leben = False
        self.type = 'npc'

        #NPC Characteristics
        self.health = stats['health']
        self.speed = stats['speed']
        self.OG_speed = self.speed
        self.mind = stats['mind']
        self.state = stats['state']
        self.OG_state = self.state
        self.atcktype = stats['atcktype']
        self.name = stats['name']
        
        if stats['dmg'] != 3.1415:
            self.dmg = stats['dmg']
        else:
            self.dmg = random.choice([0,0,1])
        self.atckrate = stats['atckrate']

        self.range = 5

        #Npc actions
        self.dead = False
        self.moving = False
        self.attacking = False
        self.hurting = False
        self.player_in_view = False

        #Textures and animations
        self.texture_path = texture # Used for creating new NPCS
        self.texture = pygame.image.load(texture).convert_alpha()
        self.texturerect = self.texture.get_rect()
        
        self.stand_texture = [self.texture.subsurface(0,0,64,128).convert_alpha(), self.texture.subsurface(64,0,64,128).convert_alpha(), self.texture.subsurface(128,0,64,128).convert_alpha(), self.texture.subsurface(192,0,64,128).convert_alpha(), self.texture.subsurface(256,0,64,128).convert_alpha(), self.texture.subsurface(320,0,64,128).convert_alpha(), self.texture.subsurface(384,0,64,128).convert_alpha(), self.texture.subsurface(448,0,64,128).convert_alpha()]
        self.front_texture = [self.texture.subsurface(0,128,64,128).convert_alpha(), self.texture.subsurface(64,128,64,128).convert_alpha(), self.texture.subsurface(128,128,64,128).convert_alpha(), self.texture.subsurface(192,128,64,128).convert_alpha(), self.texture.subsurface(256,128,64,128).convert_alpha(), self.texture.subsurface(320,128,64,128).convert_alpha(), self.texture.subsurface(384,128,64,128).convert_alpha(), self.texture.subsurface(448,128,64,128).convert_alpha(), self.texture.subsurface(512,128,64,128).convert_alpha(), self.texture.subsurface(576,128,64,128).convert_alpha()]
        self.frontright_texture = [self.texture.subsurface(0,256,64,128).convert_alpha(), self.texture.subsurface(64,256,64,128).convert_alpha(), self.texture.subsurface(128,256,64,128).convert_alpha(), self.texture.subsurface(192,256,64,128).convert_alpha(), self.texture.subsurface(256,256,64,128).convert_alpha(), self.texture.subsurface(320,256,64,128).convert_alpha(), self.texture.subsurface(384,256,64,128).convert_alpha(), self.texture.subsurface(448,256,64,128).convert_alpha(), self.texture.subsurface(512,256,64,128).convert_alpha(), self.texture.subsurface(576,256,64,128).convert_alpha()]
        self.right_texture = [self.texture.subsurface(0,384,64,128).convert_alpha(), self.texture.subsurface(64,384,64,128).convert_alpha(), self.texture.subsurface(128,384,64,128).convert_alpha(), self.texture.subsurface(192,384,64,128).convert_alpha(), self.texture.subsurface(256,384,64,128).convert_alpha(), self.texture.subsurface(320,384,64,128).convert_alpha(), self.texture.subsurface(384,384,64,128).convert_alpha(), self.texture.subsurface(448,384,64,128).convert_alpha(), self.texture.subsurface(512,384,64,128).convert_alpha(), self.texture.subsurface(576,384,64,128).convert_alpha()]
        self.backright_texture = [self.texture.subsurface(0,512,64,128).convert_alpha(), self.texture.subsurface(64,512,64,128).convert_alpha(), self.texture.subsurface(128,512,64,128).convert_alpha(), self.texture.subsurface(192,512,64,128).convert_alpha(), self.texture.subsurface(256,512,64,128).convert_alpha(), self.texture.subsurface(320,512,64,128).convert_alpha(), self.texture.subsurface(384,512,64,128).convert_alpha(), self.texture.subsurface(448,512,64,128).convert_alpha(), self.texture.subsurface(512,512,64,128).convert_alpha(), self.texture.subsurface(576,512,64,128).convert_alpha()]
        self.back_texture = [self.texture.subsurface(0,640,64,128).convert_alpha(), self.texture.subsurface(64,640,64,128).convert_alpha(), self.texture.subsurface(128,640,64,128).convert_alpha(), self.texture.subsurface(192,640,64,128).convert_alpha(), self.texture.subsurface(256,640,64,128).convert_alpha(), self.texture.subsurface(320,640,64,128).convert_alpha(), self.texture.subsurface(384,640,64,128).convert_alpha(), self.texture.subsurface(448,640,64,128).convert_alpha(), self.texture.subsurface(512,640,64,128).convert_alpha(), self.texture.subsurface(576,640,64,128).convert_alpha()]
        
        self.backleft_texture = []
        self.left_texture = []
        self.frontleft_texture = []

        for frame in self.backright_texture:
            self.backleft_texture.append(pygame.transform.flip(frame, True, False))
        for frame in self.right_texture:
            self.left_texture.append(pygame.transform.flip(frame, True, False))
        for frame in self.frontright_texture:
            self.frontleft_texture.append(pygame.transform.flip(frame, True, False))

        self.die_texture = [self.texture.subsurface(0,768,64,128).convert_alpha(), self.texture.subsurface(64,768,64,128).convert_alpha(), self.texture.subsurface(128,768,64,128).convert_alpha(), self.texture.subsurface(192,768,64,128).convert_alpha(), self.texture.subsurface(256,768,64,128).convert_alpha(), self.texture.subsurface(320,768,64,128).convert_alpha(), self.texture.subsurface(384,768,64,128).convert_alpha(), self.texture.subsurface(448,768,64,128).convert_alpha(), self.texture.subsurface(512,768,64,128).convert_alpha(), self.texture.subsurface(576,768,64,128).convert_alpha(), self.texture.subsurface(640,768,64,128).convert_alpha()]
        self.hit_texture = [self.texture.subsurface(0,896,64,128).convert_alpha(), self.texture.subsurface(64,896,64,128).convert_alpha(), self.texture.subsurface(128,896,64,128).convert_alpha(), self.texture.subsurface(192,896,64,128).convert_alpha(), self.texture.subsurface(256,896,64,128).convert_alpha(), self.texture.subsurface(320,896,64,128).convert_alpha()]
        self.hurt_texture = [self.die_texture[0]]
        self.current_frame = 1
        self.update_timer = 0

        #Creating the sprite rect is awful, I know. Keeps it from entering walls.
        self.sprite = SPRITES.Sprite(self.front_texture[1], self.ID, [self.rect.centerx - int(SETTINGS.tile_size / 12), self.rect.centery - int(SETTINGS.tile_size / 10)], 'npc', self)

        #The position in SETTINGS.all_sprites of this NPC
        self.num = len(SETTINGS.all_sprites)-1