import pygame


class Player(pygame.sprite.Sprite):
    death = [pygame.image.load('Images/death1.png'), pygame.image.load('Images/death2.png'),
             pygame.image.load('Images/death3.png'),
             pygame.image.load('Images/death4.png'), pygame.image.load('Images/death5.png'),
             pygame.image.load('Images/death6.png'),
             pygame.image.load('Images/death7.png'), pygame.image.load('Images/death8.png'),
             pygame.image.load('Images/death9.png'),
             pygame.image.load('Images/death10.png'), pygame.image.load('Images/death11.png'),
             pygame.image.load('Images/death12.png'),
             pygame.image.load('Images/death13.png'), pygame.image.load('Images/death14.png'),
             pygame.image.load('Images/death15.png'),
             pygame.image.load('Images/death16.png'), pygame.image.load('Images/death17.png'),
             pygame.image.load('Images/death18.png'),pygame.image.load('Images/death19.png'),
             pygame.image.load('Images/death20.png')]
    p1walkLeft = [pygame.image.load('Images/p1left.png'), pygame.image.load('Images/p1left1.png'),
             pygame.image.load('Images/p1left2.png'),
             pygame.image.load('Images/p1left3.png'), pygame.image.load('Images/p1left2.png'),
             pygame.image.load('Images/p1left1.png'), pygame.image.load('Images/p1left.png')]
    p1walkLeftshield = [pygame.image.load('Images/p1leftshield.png'), pygame.image.load('Images/p1left1shield.png'),
                  pygame.image.load('Images/p1left2shield.png'),
                  pygame.image.load('Images/p1left3shield.png'), pygame.image.load('Images/p1left2shield.png'),
                  pygame.image.load('Images/p1left1shield.png'), pygame.image.load('Images/p1leftshield.png')]
    p1walkRight = [pygame.image.load('Images/p1right.png'), pygame.image.load('Images/p1right1.png'),
                  pygame.image.load('Images/p1right2.png'),
                  pygame.image.load('Images/p1right3.png'), pygame.image.load('Images/p1right2.png'),
                  pygame.image.load('Images/p1right1.png'), pygame.image.load('Images/p1right.png')]
    p1walkRightshield = [pygame.image.load('Images/p1rightshield.png'), pygame.image.load('Images/p1right1shield.png'),
                   pygame.image.load('Images/p1right2shield.png'),
                   pygame.image.load('Images/p1right3shield.png'), pygame.image.load('Images/p1right2shield.png'),
                   pygame.image.load('Images/p1right1shield.png'), pygame.image.load('Images/p1rightshield.png')]
    p1walkFront = [pygame.image.load('Images/p1front.png'), pygame.image.load('Images/p1front1.png'),
                   pygame.image.load('Images/p1front2.png'),
                   pygame.image.load('Images/p1front3.png'), pygame.image.load('Images/p1front2.png'),
                   pygame.image.load('Images/p1front1.png'), pygame.image.load('Images/p1front.png')]
    p1walkFrontshield = [pygame.image.load('Images/p1frontshield.png'), pygame.image.load('Images/p1front1shield.png'),
                   pygame.image.load('Images/p1front2shield.png'),
                   pygame.image.load('Images/p1front3shield.png'), pygame.image.load('Images/p1front2shield.png'),
                   pygame.image.load('Images/p1front1shield.png'), pygame.image.load('Images/p1frontshield.png')]
    p1walkBack = [pygame.image.load('Images/p1back.png'), pygame.image.load('Images/p1back1.png'),
                   pygame.image.load('Images/p1back2.png'),
                   pygame.image.load('Images/p1back3.png'), pygame.image.load('Images/p1back2.png'),
                   pygame.image.load('Images/p1back1.png'), pygame.image.load('Images/p1back.png')]
    p1walkBackshield = [pygame.image.load('Images/p1backshield.png'), pygame.image.load('Images/p1back1shield.png'),
                  pygame.image.load('Images/p1back2shield.png'),
                  pygame.image.load('Images/p1back3shield.png'), pygame.image.load('Images/p1back2shield.png'),
                  pygame.image.load('Images/p1back1shield.png'), pygame.image.load('Images/p1backshield.png')]
    p2walkLeft = [pygame.image.load('Images/p2left.png'), pygame.image.load('Images/p2left1.png'),
                  pygame.image.load('Images/p2left2.png'),
                  pygame.image.load('Images/p2left3.png'), pygame.image.load('Images/p2left2.png'),
                  pygame.image.load('Images/p2left1.png'), pygame.image.load('Images/p2left.png')]
    p2walkRight = [pygame.image.load('Images/p2right.png'), pygame.image.load('Images/p2right1.png'),
                   pygame.image.load('Images/p2right2.png'),
                   pygame.image.load('Images/p2right3.png'), pygame.image.load('Images/p2right2.png'),
                   pygame.image.load('Images/p2right1.png'), pygame.image.load('Images/p2right.png')]
    p2walkFront = [pygame.image.load('Images/p2front.png'), pygame.image.load('Images/p2front1.png'),
                   pygame.image.load('Images/p2front2.png'),
                   pygame.image.load('Images/p2front3.png'), pygame.image.load('Images/p2front2.png'),
                   pygame.image.load('Images/p2front1.png'), pygame.image.load('Images/p2front.png')]
    p2walkBack = [pygame.image.load('Images/p2back.png'), pygame.image.load('Images/p2back1.png'),
                  pygame.image.load('Images/p2back2.png'),
                  pygame.image.load('Images/p2back3.png'), pygame.image.load('Images/p2back2.png'),
                  pygame.image.load('Images/p2back1.png'), pygame.image.load('Images/p2back.png')]
    p2walkLeftshield = [pygame.image.load('Images/p2leftshield.png'), pygame.image.load('Images/p2left1shield.png'),
                  pygame.image.load('Images/p2left2shield.png'),
                  pygame.image.load('Images/p2left3shield.png'), pygame.image.load('Images/p2left2shield.png'),
                  pygame.image.load('Images/p2left1shield.png'), pygame.image.load('Images/p2leftshield.png')]
    p2walkRightshield = [pygame.image.load('Images/p2rightshield.png'), pygame.image.load('Images/p2right1shield.png'),
                   pygame.image.load('Images/p2right2shield.png'),
                   pygame.image.load('Images/p2right3shield.png'), pygame.image.load('Images/p2right2shield.png'),
                   pygame.image.load('Images/p2right1shield.png'), pygame.image.load('Images/p2rightshield.png')]
    p2walkFrontshield = [pygame.image.load('Images/p2frontshield.png'), pygame.image.load('Images/p2front1shield.png'),
                   pygame.image.load('Images/p2front2shield.png'),
                   pygame.image.load('Images/p2front3shield.png'), pygame.image.load('Images/p2front2shield.png'),
                   pygame.image.load('Images/p2front1shield.png'), pygame.image.load('Images/p2frontshield.png')]
    p2walkBackshield = [pygame.image.load('Images/p2backshield.png'), pygame.image.load('Images/p2back1shield.png'),
                  pygame.image.load('Images/p2back2shield.png'),
                  pygame.image.load('Images/p2back3shield.png'), pygame.image.load('Images/p2back2shield.png'),
                  pygame.image.load('Images/p2back1shield.png'), pygame.image.load('Images/p2backshield.png')]
    # Constructor function
    def __init__(self, x, y, number):
        super().__init__()
        self.image = pygame.Surface([24, 28])
        self.image.fill((0,0,0))

        self.rect = self.image.get_rect()
        self.rect.y = y
        self.rect.x = x
        self.front = True
        self.back = False
        self.left = False
        self.right = False
        self.number = number

        self.change_x = 0
        self.change_y = 0
        self.walkCount = 0
        self.walls = None

        self.alive = True
        self.canmove = True
        self.deathCount = 0
        self.gotomenu=False

        self.speed=3
        self.superspeed=False
        self.superspeedcount=0

        self.shield=False
        self.shieldcount=0

        self.megabombs=False
        self.megabombcount = 0

    def changespeed(self, x, y):
        self.change_x += x
        self.change_y += y
        if self.superspeed and self.change_x==0 and self.change_y==0:
            self.speed=6
            if self.superspeedcount>=150:
                self.superspeed = False
                self.speed=3
                self.superspeedcount=0

    def update(self):
        if self.canmove:
            self.rect.x += self.change_x
            if self.change_x <0:
                self.left=True
                self.right=False
                self.front=False
                self.back=False
            elif self.change_x >0:
                self.left=False
                self.right=True
                self.front=False
                self.back=False
            block_hit_list = pygame.sprite.spritecollide(self, self.walls, False)
            for block in block_hit_list:
                if self.change_x > 0:
                    self.rect.right = block.rect.left
                else:
                    self.rect.left = block.rect.right
            self.rect.y += self.change_y
            if self.change_y <0:
                self.left=False
                self.right=False
                self.front=False
                self.back=True
            elif self.change_y >0:
                self.left=False
                self.right=False
                self.front=True
                self.back=False
            block_hit_list = pygame.sprite.spritecollide(self, self.walls, False)
            for block in block_hit_list:
                if self.change_y > 0:
                    self.rect.bottom = block.rect.top
                else:
                    self.rect.top = block.rect.bottom

    def draw(self, screen):
        if self.number == 1:
            screen.blit(pygame.image.load('Images2/'+str(self.megabombcount)+'megabombs.png'), (2, 0))
            if self.alive:
                if self.front:
                    if self.shield:
                        if self.change_y == 0:
                            screen.blit(pygame.image.load('Images/p1frontshield.png'),
                                        (self.rect.x, self.rect.y))
                        else:
                            if self.walkCount + 1 >= 21:
                                self.walkCount = 0
                            screen.blit(self.p1walkFrontshield[self.walkCount // 3], (self.rect.x, self.rect.y))
                            self.walkCount += 1
                    else:
                        if self.change_y == 0:
                            screen.blit(pygame.image.load('Images/p1front.png'),
                                        (self.rect.x, self.rect.y))
                        else:
                            if self.walkCount + 1 >= 21:
                                self.walkCount = 0
                            screen.blit(self.p1walkFront[self.walkCount // 3], (self.rect.x, self.rect.y))
                            self.walkCount += 1
                elif self.back:
                    if self.shield:
                        if self.change_y == 0:
                            screen.blit(pygame.image.load('Images/p1backshield.png'),
                                        (self.rect.x, self.rect.y))
                        else:
                            if self.walkCount + 1 >= 21:
                                self.walkCount = 0
                            screen.blit(self.p1walkBackshield[self.walkCount // 3], (self.rect.x, self.rect.y))
                            self.walkCount += 1
                    else:
                        if self.change_y == 0:
                            screen.blit(pygame.image.load('Images/p1back.png'),
                                        (self.rect.x, self.rect.y))
                        else:
                            if self.walkCount + 1 >= 21:
                                self.walkCount = 0
                            screen.blit(self.p1walkBack[self.walkCount // 3], (self.rect.x, self.rect.y))
                            self.walkCount += 1
                elif self.left:
                    if self.shield:
                        if self.change_x == 0:
                            screen.blit(pygame.image.load('Images/p1leftshield.png'),
                                        (self.rect.x, self.rect.y))
                        else:
                            if self.walkCount + 1 >= 21:
                                self.walkCount = 0
                            screen.blit(self.p1walkLeftshield[self.walkCount // 3], (self.rect.x, self.rect.y))
                            self.walkCount += 1
                    else:
                        if self.change_x == 0:
                            screen.blit(pygame.image.load('Images/p1left.png'),
                                        (self.rect.x, self.rect.y))
                        else:
                            if self.walkCount + 1 >= 21:
                                self.walkCount = 0
                            screen.blit(self.p1walkLeft[self.walkCount // 3], (self.rect.x, self.rect.y))
                            self.walkCount += 1
                elif self.right:
                    if self.shield:
                        if self.change_x == 0:
                            screen.blit(pygame.image.load('Images/p1rightshield.png'),
                                        (self.rect.x, self.rect.y))
                        else:
                            if self.walkCount + 1 >= 21:
                                self.walkCount = 0
                            screen.blit(self.p1walkRightshield[self.walkCount // 3], (self.rect.x, self.rect.y))
                            self.walkCount += 1
                    else:
                        if self.change_x == 0:
                            screen.blit(pygame.image.load('Images/p1right.png'),
                                        (self.rect.x, self.rect.y))
                        else:
                            if self.walkCount + 1 >= 21:
                                self.walkCount = 0
                            screen.blit(self.p1walkRight[self.walkCount // 3], (self.rect.x, self.rect.y))
                            self.walkCount += 1
        elif self.number == 2:
            screen.blit(pygame.image.load('Images2/'+str(self.megabombcount)+'megabombs.png'), (415, 0))
            if self.alive:
                if self.front:
                    if self.shield:
                        if self.change_y == 0:
                            screen.blit(pygame.image.load('Images/p2frontshield.png'),
                                        (self.rect.x, self.rect.y))
                        else:
                            if self.walkCount + 1 >= 21:
                                self.walkCount = 0
                            screen.blit(self.p2walkFrontshield[self.walkCount // 3], (self.rect.x, self.rect.y))
                            self.walkCount += 1
                    else:
                        if self.change_y == 0:
                            screen.blit(pygame.image.load('Images/p2front.png'),
                                        (self.rect.x, self.rect.y))
                        else:
                            if self.walkCount + 1 >= 21:
                                self.walkCount = 0
                            screen.blit(self.p2walkFront[self.walkCount // 3], (self.rect.x, self.rect.y))
                            self.walkCount += 1
                elif self.back:
                    if self.shield:
                        if self.change_y == 0:
                            screen.blit(pygame.image.load('Images/p2backshield.png'),
                                        (self.rect.x, self.rect.y))
                        else:
                            if self.walkCount + 1 >= 21:
                                self.walkCount = 0
                            screen.blit(self.p2walkBackshield[self.walkCount // 3], (self.rect.x, self.rect.y))
                            self.walkCount += 1
                    else:
                        if self.change_y == 0:
                            screen.blit(pygame.image.load('Images/p2back.png'),
                                        (self.rect.x, self.rect.y))
                        else:
                            if self.walkCount + 1 >= 21:
                                self.walkCount = 0
                            screen.blit(self.p2walkBack[self.walkCount // 3], (self.rect.x, self.rect.y))
                            self.walkCount += 1
                elif self.left:
                    if self.shield:
                        if self.change_x == 0:
                            screen.blit(pygame.image.load('Images/p2leftshield.png'),
                                        (self.rect.x, self.rect.y))
                        else:
                            if self.walkCount + 1 >= 21:
                                self.walkCount = 0
                            screen.blit(self.p2walkLeftshield[self.walkCount // 3], (self.rect.x, self.rect.y))
                            self.walkCount += 1
                    else:
                        if self.change_x == 0:
                            screen.blit(pygame.image.load('Images/p2left.png'),
                                        (self.rect.x, self.rect.y))
                        else:
                            if self.walkCount + 1 >= 21:
                                self.walkCount = 0
                            screen.blit(self.p2walkLeft[self.walkCount // 3], (self.rect.x, self.rect.y))
                            self.walkCount += 1
                elif self.right:
                    if self.shield:
                        if self.change_x == 0:
                            screen.blit(pygame.image.load('Images/p2rightshield.png'),
                                        (self.rect.x, self.rect.y))
                        else:
                            if self.walkCount + 1 >= 21:
                                self.walkCount = 0
                            screen.blit(self.p2walkRightshield[self.walkCount // 3], (self.rect.x, self.rect.y))
                            self.walkCount += 1
                    else:
                        if self.change_x == 0:
                            screen.blit(pygame.image.load('Images/p2right.png'),
                                        (self.rect.x, self.rect.y))
                        else:
                            if self.walkCount + 1 >= 21:
                                self.walkCount = 0
                            screen.blit(self.p2walkRight[self.walkCount // 3], (self.rect.x, self.rect.y))
                            self.walkCount += 1
        if self.alive == False and self.deathCount < 200:
            screen.blit(self.death[self.deathCount // 10], (self.rect.x, self.rect.y))
            self.deathCount += 1
        if self.deathCount >= 200:
            self.rect.x = 1000
            self.gotomenu=True
    def reset(self,x,y):
        self.gotomenu = False
        self.alive = True
        self.deathCount = 0
        self.rect.x = x
        self.rect.y = y
        self.canmove = True
        self.front = True
        self.change_x=0
        self.change_y=0
        self.superspeed=False
        self.speed=3
        self.shield=False
        self.megabombs=False
        self.megabombcount=0
class Wall(pygame.sprite.Sprite):
    def __init__(self, x, y, width, height):
        super().__init__()
        self.image = pygame.Surface([width,height], pygame.SRCALPHA, 32)
        image = self.image.convert_alpha()

        self.rect = self.image.get_rect()
        self.rect.y = y
        self.rect.x = x
class powerup(pygame.sprite.Sprite):
    superspeedanimation=[pygame.image.load('Images/superspeed1.png'), pygame.image.load('Images/superspeed2.png'),
             pygame.image.load('Images/superspeed3.png'), pygame.image.load('Images/superspeed3.png'),
             pygame.image.load('Images/superspeed2.png'), pygame.image.load('Images/superspeed1.png')]
    shieldanimation = [pygame.image.load('Images/shield1.png'), pygame.image.load('Images/shield2.png'),
                           pygame.image.load('Images/shield3.png'), pygame.image.load('Images/shield3.png'),
                           pygame.image.load('Images/shield2.png'), pygame.image.load('Images/shield1.png')]
    megabombanimation = [pygame.image.load('Images2/megabombicon1.png'), pygame.image.load('Images2/megabombicon2.png'),
                       pygame.image.load('Images2/megabombicon3.png'), pygame.image.load('Images2/megabombicon3.png'),
                       pygame.image.load('Images2/megabombicon2.png'), pygame.image.load('Images2/megabombicon1.png')]
    def __init__(self, x, y, number):
        super().__init__()
        self.image = pygame.Surface([22, 28], pygame.SRCALPHA, 32)
        image = self.image.convert_alpha()
        self.rect = self.image.get_rect()
        self.rect.y = y
        self.rect.x = x
        self.number = number
        self.spawntimer=0
        self.respawntimer=0
        self.exists=True
        self.animationcount=0
    def draw(self, screen):
        if self.number==1:
            if self.exists and self.spawntimer>50:
                if self.animationcount + 1 >= 30:
                    self.animationcount = 0
                screen.blit(self.superspeedanimation[self.animationcount // 5], (self.rect.x, self.rect.y))
                self.animationcount += 1
        elif self.number==2:
            if self.exists and self.spawntimer > 50:
                if self.animationcount + 1 >= 30:
                    self.animationcount = 0
                screen.blit(self.shieldanimation[self.animationcount // 5], (self.rect.x, self.rect.y))
                self.animationcount += 1
        else:
            if self.exists and self.spawntimer > 50:
                if self.animationcount + 1 >= 30:
                    self.animationcount = 0
                screen.blit(self.megabombanimation[self.animationcount // 5], (self.rect.x, self.rect.y))
                self.animationcount += 1
    def reset(self):
        self.spawntimer=0
        self.respawntimer=0
        self.exists=True
class bomb(pygame.sprite.Sprite):
    def __init__(self, x, y, width, height, bomb_count, bomb_type):
        super().__init__()
        self.image = pygame.Surface([22, 28], pygame.SRCALPHA, 32)
        image = self.image.convert_alpha()
        self.rect = self.image.get_rect()
        self.rect.y = y
        self.rect.x = x
        self.width = width
        self.height = height
        self.bomb_count = bomb_count
        self.bomb_type = bomb_type

        self.walls = None
        self.leftcheck = self.rect.x - 32
        self.rightcheck = self.rect.x + self.width
        self.upcheck = self.rect.y - 32
        self.downcheck = self.rect.y + self.height
        self.expleft = True
        self.doubleexpleft = True
        self.expright = True
        self.doubleexpright = True
        self.expup = True
        self.doubleexpup = True
        self.expdown = True
        self.doubleexpdown = True
        self.expboxlist = []

    def draw(self, screen):
        if self.bomb_count < 30:
            if self.bomb_type==0:
                screen.blit(pygame.image.load('Images/bomb3.png'), (self.rect.x, self.rect.y))
            else:
                screen.blit(pygame.image.load('Images2/megabomb3.png'), (self.rect.x, self.rect.y))
        elif self.bomb_count < 60:
            if self.bomb_type == 0:
                screen.blit(pygame.image.load('Images/bomb2.png'), (self.rect.x, self.rect.y))
            else:
                screen.blit(pygame.image.load('Images2/megabomb2.png'), (self.rect.x, self.rect.y))
        elif self.bomb_count < 90:
            if self.bomb_type == 0:
                screen.blit(pygame.image.load('Images/bomb1.png'), (self.rect.x, self.rect.y))
            else:
                screen.blit(pygame.image.load('Images2/megabomb1.png'), (self.rect.x, self.rect.y))
        elif self.bomb_count < 120:
            if self.bomb_type==0:
                for i in self.walls:
                    if i.rect.collidepoint(self.leftcheck,self.rect.y):
                        self.expleft = False
                    if i.rect.collidepoint(self.rightcheck,self.rect.y):
                        self.expright = False
                    if i.rect.collidepoint(self.rect.x,self.upcheck):
                        self.expup = False
                    if i.rect.collidepoint(self.rect.x,self.downcheck):
                        self.expdown = False
                screen.blit(pygame.image.load('Images/explosion.png'), (self.rect.x, self.rect.y))
                self.expboxlist.append(pygame.Rect(self.rect.x, self.rect.y, 32, 32))
                if self.expleft:
                    screen.blit(pygame.image.load('Images/explosion.png'), (self.leftcheck, self.rect.y))
                    self.expboxlist.append(pygame.Rect(self.leftcheck, self.rect.y, 32, 32))
                    screen.blit(pygame.image.load('Images/explosion.png'), (self.leftcheck+16, self.rect.y))
                    self.expboxlist.append(pygame.Rect(self.leftcheck+16, self.rect.y, 32, 32))
                if self.expright:
                    screen.blit(pygame.image.load('Images/explosion.png'), (self.rightcheck, self.rect.y))
                    self.expboxlist.append(pygame.Rect(self.rightcheck, self.rect.y, 32, 32))
                    screen.blit(pygame.image.load('Images/explosion.png'), (self.rightcheck-16, self.rect.y))
                    self.expboxlist.append(pygame.Rect(self.rightcheck-16, self.rect.y, 32, 32))
                if self.expup:
                    screen.blit(pygame.image.load('Images/explosion.png'), (self.rect.x, self.upcheck))
                    self.expboxlist.append(pygame.Rect(self.rect.x, self.upcheck, 32, 32))
                    screen.blit(pygame.image.load('Images/explosion.png'), (self.rect.x, self.upcheck+16))
                    self.expboxlist.append(pygame.Rect(self.rect.x, self.upcheck+16, 32, 32))
                if self.expdown:
                    screen.blit(pygame.image.load('Images/explosion.png'), (self.rect.x, self.downcheck))
                    self.expboxlist.append(pygame.Rect(self.rect.x, self.downcheck, 32, 32))
                    screen.blit(pygame.image.load('Images/explosion.png'), (self.rect.x, self.downcheck-16))
                    self.expboxlist.append(pygame.Rect(self.rect.x, self.downcheck-16, 32, 32))
            elif self.bomb_type==1:
                for i in self.walls:
                    if i.rect.collidepoint(self.leftcheck, self.rect.y):
                        self.expleft = False
                    if i.rect.collidepoint(self.leftcheck-32, self.rect.y):
                            self.doubleexpleft = False
                    if i.rect.collidepoint(self.rightcheck, self.rect.y):
                        self.expright = False
                    if i.rect.collidepoint(self.rightcheck+32, self.rect.y):
                            self.doubleexpright = False
                    if i.rect.collidepoint(self.rect.x, self.upcheck):
                        self.expup = False
                    if i.rect.collidepoint(self.rect.x, self.upcheck-32):
                            self.doubleexpup = False
                    if i.rect.collidepoint(self.rect.x, self.downcheck):
                        self.expdown = False
                    if i.rect.collidepoint(self.rect.x, self.downcheck+32):
                            self.doubleexpdown = False
                screen.blit(pygame.image.load('Images/explosion.png'), (self.rect.x, self.rect.y))
                self.expboxlist.append(pygame.Rect(self.rect.x, self.rect.y, 32, 32))
                if self.expleft:
                    screen.blit(pygame.image.load('Images/explosion.png'), (self.leftcheck, self.rect.y))
                    self.expboxlist.append(pygame.Rect(self.leftcheck, self.rect.y, 32, 32))
                    screen.blit(pygame.image.load('Images/explosion.png'), (self.leftcheck + 16, self.rect.y))
                    self.expboxlist.append(pygame.Rect(self.leftcheck + 16, self.rect.y, 32, 32))
                    if self.doubleexpleft:
                        screen.blit(pygame.image.load('Images/explosion.png'), (self.leftcheck-32, self.rect.y))
                        self.expboxlist.append(pygame.Rect(self.leftcheck-32, self.rect.y, 32, 32))
                        screen.blit(pygame.image.load('Images/explosion.png'), (self.leftcheck-16, self.rect.y))
                        self.expboxlist.append(pygame.Rect(self.leftcheck-16, self.rect.y, 32, 32))
                if self.expright:
                    screen.blit(pygame.image.load('Images/explosion.png'), (self.rightcheck, self.rect.y))
                    self.expboxlist.append(pygame.Rect(self.rightcheck, self.rect.y, 32, 32))
                    screen.blit(pygame.image.load('Images/explosion.png'), (self.rightcheck - 16, self.rect.y))
                    self.expboxlist.append(pygame.Rect(self.rightcheck - 16, self.rect.y, 32, 32))
                    if self.doubleexpright:
                        screen.blit(pygame.image.load('Images/explosion.png'), (self.rightcheck+32, self.rect.y))
                        self.expboxlist.append(pygame.Rect(self.rightcheck+32, self.rect.y, 32, 32))
                        screen.blit(pygame.image.load('Images/explosion.png'), (self.rightcheck+16, self.rect.y))
                        self.expboxlist.append(pygame.Rect(self.rightcheck+16, self.rect.y, 32, 32))
                if self.expup:
                    screen.blit(pygame.image.load('Images/explosion.png'), (self.rect.x, self.upcheck))
                    self.expboxlist.append(pygame.Rect(self.rect.x, self.upcheck, 32, 32))
                    screen.blit(pygame.image.load('Images/explosion.png'), (self.rect.x, self.upcheck + 16))
                    self.expboxlist.append(pygame.Rect(self.rect.x, self.upcheck + 16, 32, 32))
                    if self.doubleexpup:
                        screen.blit(pygame.image.load('Images/explosion.png'), (self.rect.x, self.upcheck-32))
                        self.expboxlist.append(pygame.Rect(self.rect.x, self.upcheck-32, 32, 32))
                        screen.blit(pygame.image.load('Images/explosion.png'), (self.rect.x, self.upcheck-16))
                        self.expboxlist.append(pygame.Rect(self.rect.x, self.upcheck-16, 32, 32))
                if self.expdown:
                    screen.blit(pygame.image.load('Images/explosion.png'), (self.rect.x, self.downcheck))
                    self.expboxlist.append(pygame.Rect(self.rect.x, self.downcheck, 32, 32))
                    screen.blit(pygame.image.load('Images/explosion.png'), (self.rect.x, self.downcheck - 16))
                    self.expboxlist.append(pygame.Rect(self.rect.x, self.downcheck - 16, 32, 32))
                    if self.doubleexpdown:
                        screen.blit(pygame.image.load('Images/explosion.png'), (self.rect.x, self.downcheck+32))
                        self.expboxlist.append(pygame.Rect(self.rect.x, self.downcheck+32, 32, 32))
                        screen.blit(pygame.image.load('Images/explosion.png'), (self.rect.x, self.downcheck+16))
                        self.expboxlist.append(pygame.Rect(self.rect.x, self.downcheck+16, 32, 32))
[(5, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (5, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (6, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (7, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (7, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (8, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (9, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (9, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (10, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (11, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (11, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (12, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (13, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (13, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (14, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (15, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (15, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (16, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (16, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (17, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (18, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (18, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (19, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (20, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (20, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (21, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (21, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (22, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (22, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (23, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (24, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (24, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (25, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (25, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (26, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (26, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (27, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (28, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (28, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (29, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (29, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (30, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (30, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (31, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (32, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (32, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (33, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (33, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (34, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (34, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (35, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (36, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (36, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (37, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (37, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (38, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (38, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (39, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (40, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (40, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (41, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (41, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (42, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (42, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (43, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (44, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (44, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (45, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (45, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (46, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (46, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (47, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (48, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (48, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (49, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (49, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (50, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (50, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (51, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (52, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (52, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (53, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (53, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (54, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (54, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (55, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (56, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (56, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (57, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (57, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (58, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (58, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (59, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (60, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (60, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (61, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (61, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (62, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (62, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (63, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (64, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (64, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (65, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (65, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (66, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (66, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (67, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (68, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (68, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (69, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (69, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (70, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (70, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (71, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (72, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (72, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (73, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (73, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (74, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (74, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (75, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (76, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (76, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (77, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (77, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (78, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (78, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (79, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (80, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (80, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (81, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (81, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (85, 'pygame.Surface', 'pygame.Surface', False, 'import pygame\n'), (347, 'pygame.Surface', 'pygame.Surface', False, 'import pygame\n'), (354, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (354, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (355, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (355, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (356, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (356, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (357, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (357, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (358, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (358, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (359, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (359, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (360, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (360, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (361, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (361, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (362, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (362, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (365, 'pygame.Surface', 'pygame.Surface', False, 'import pygame\n'), (401, 'pygame.Surface', 'pygame.Surface', False, 'import pygame\n'), (140, 'pygame.sprite.spritecollide', 'pygame.sprite.spritecollide', False, 'import pygame\n'), (157, 'pygame.sprite.spritecollide', 'pygame.sprite.spritecollide', False, 'import pygame\n'), (429, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (431, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (434, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (436, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (439, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (441, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (171, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (180, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (453, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (454, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (190, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (199, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (250, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (259, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (456, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (457, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (458, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (459, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (461, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (462, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (463, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (464, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (466, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (467, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (468, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (469, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (471, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (472, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (473, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (474, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (493, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (494, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (209, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (218, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (269, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (278, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (496, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (497, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (498, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (499, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (506, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (507, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (508, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (509, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (516, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (517, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (518, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (519, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (526, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (527, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (528, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (529, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (228, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (237, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (288, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (297, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (501, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (502, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (503, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (504, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (511, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (512, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (513, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (514, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (521, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (522, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (523, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (524, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (531, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (532, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (533, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (534, 'pygame.Rect', 'pygame.Rect', False, 'import pygame\n'), (307, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n'), (316, 'pygame.image.load', 'pygame.image.load', False, 'import pygame\n')]