BrunoSDomingues / Mother-Lord-Game

0 stars 0 forks source link

jogo #2

Open Gustavobb opened 6 years ago

Gustavobb commented 6 years ago

-- coding: utf-8 --

""" Created on Fri Apr 27 11:01:20 2018

@author: gubeb, beni, bruno """

import pygame from matplotlib.pyplot import imread from pygame.locals import K_w, K_ESCAPE, K_s, K_a, K_SPACE, K_d, K_n import random

---------------VARIAVEIS----------------

groups

buttong = pygame.sprite.Group()
mapbut = pygame.sprite.Group() cont = pygame.sprite.Group() okay_group = pygame.sprite.Group() helpbu = pygame.sprite.Group() helpbu2 = pygame.sprite.Group() shop_but = pygame.sprite.Group()

variavel

criado=0 lista = [] FPS = 60 velocidade_aumentada = 0 contador_de_shop_vida = 1 contador_de_shop_nuke = 1 contador_de_shop_velo = 1

dimensoes

display_width, display_high = 1441,767

cores

black = (0,0,0) red = (189, 34, 32) white = (255,255,255)

-------------INICIALIZAÇÃO--------------

pygame.font.init() pygame.init() myfont = pygame.font.SysFont("Viner Hand ITC", 50) gameDisplay = pygame.display.set_mode((display_width, display_high)) pygame.display.set_caption('Mother Lord') CLOCK = pygame.time.Clock()

-------------PERSONAGEM------------------

walkRight = [pygame.image.load('hm{}.jpg'.format(i)) for i in range(1, 7)] st = [pygame.image.load('stand{}.jpg'.format(i)) for i in range(1,6)] en = [pygame.image.load('Dem{}.png'.format(i)) for i in range (1,10)] tirosumindo = [pygame.image.load('tiros{}.png'.format(i)) for i in range (1,4)] caveiramorte = [pygame.image.load('cav{}.png'.format(i)) for i in range (1,8)]

---------------ITENS----------------------

tiro2 = pygame.image.load('gCSovF5.png') tiro3 = pygame.transform.scale(tiro2,(40,30)) life = pygame.image.load('pixel-heart-2779422_960_720.png') life_hearth = pygame.transform.scale(life,(60,60)) Menos_1 = pygame.image.load('red-skull-hi.png') img_morte = pygame.transform.scale(Menos_1,(60,60)) pote = pygame.image.load('canva-heat-and-coin-pixel-MACARo_yXQY.png') pote_ouro = pygame.transform.scale(pote,(50,50)) n = pygame.image.load('bb288fad854e79d.png') nuketown = pygame.transform.scale(n,(30,50)) seta = pygame.image.load('v.png') seta_loja = pygame.transform.scale(seta,(50,50))

-----------------BOTÕES------------------

play = 'play button.png' Quit = 'quit.png' Credits = 'credit.png' map1 = 'map1.png' map2 = 'map2.png' map3 = 'map3.png' okay = 'back.png' foward = 'pp.png' help_inicial = 'pixil-frame-0.png' continuegame = 'pixil-frame-1.png' shop = 'shopp.png' shop_heart = 'hee.png' shop_velo = 'nuke.png' shop_nuke = 'velo.png'

---------------TELA-------------------------

over = pygame.image.load("game over.jpg").convert() game_over = pygame.transform.scale(over, (display_width, display_high))

over2 = pygame.image.load("finl 2.JPG").convert() game_over2 = pygame.transform.scale(over2, (display_width, display_high))

over3 = pygame.image.load("Capturar.JPG2.JPG").convert() game_over3 = pygame.transform.scale(over3, (display_width, display_high))

menu_pequeno = pygame.image.load('blizzardskull.png').convert() menu = pygame.transform.scale(menu_pequeno,(display_width,display_high)) menu2 = pygame.image.load('Capturar.PNG').convert() MENU = pygame.transform.scale(menu2, (display_width, display_high))

men_ajuda = pygame.image.load('Capturar2.PNG').convert() menu_ajuda = pygame.transform.scale(men_ajuda,(display_width,display_high))

he1 = pygame.image.load('ajudaagem.PNG') help_1 = pygame.transform.scale(he1,(display_width,display_high))

text = pygame.image.load('Bragoncius.png') star_wars = pygame.image.load('credits.png') star_wars2 = pygame.transform.scale(star_wars, (display_width, display_high)) TextSurf = pygame.image.load('picturetopeople.org-86bcced5542f852f68a1a92394e8d4716e7553f0288521364a.png')

upgrade = pygame.image.load('UPGRADES.PNG') upgradeloja = pygame.transform.scale(upgrade, (display_width, display_high))

coin = [pygame.image.load('Coin{}.png'.format(i)) for i in range(1, 7)]

--------------BOOLS------------------------

rodando = True game = False button = True mapas = False pause = False ajuda = False creditss = False cria_v = False cria_m = False cria_o = False cria_n = False helpi1 = False helpi2 = False shopping = False

-------------MUSICAS--------------------

buttonmusic = pygame.mixer.Sound('Drop Sword-SoundBible.com-768774345.wav') shoot_music = pygame.mixer.Sound('Laser Blaster-SoundBible.com-1388608841-[AudioTrimmer.com].wav') Life_one = pygame.mixer.Sound('classic_hurt.wav') life_gain = pygame.mixer.Sound('162473kastenfroschsuccessful.wav') atomicbomb = pygame.mixer.Sound('Bomb 2-SoundBible.com-953367492.wav')

--------------------CLASS BUTTON-----------------

class Button(pygame.sprite.Sprite):

def __init__(self,img,pos_x,pos_y):

    height, width, channels = imread(img).shape

    pygame.sprite.Sprite.__init__(self)
    self.image=pygame.image.load(img)
    self.rect = self.image.get_rect()
    self.rect.x = pos_x
    self.rect.y = pos_y
    self.x = [pos_x,pos_x+width]
    self.y = [pos_y,pos_y+height]

------------------CLASS PLAYER-------------------

class Player(pygame.sprite.Sprite):

def __init__(self, vel):
    pygame.sprite.Sprite.__init__(self)
    self.vel = vel
    self.direcao = "parado"
    self.para = "centro"
    self.count = 0
    self.walkCount = 0
    self.standCount = 0
    self.contadorshoot = 0
    self.rect = tiro3.get_rect()
    self.contadorinimigo = 0

def marcarlocal(self,x,y):
    self.x = x
    self.y = y
    self.xvel = 0
    self.yvel = 0

def teclas(self):
    global lista, In, criado, pause, t, P, nivel, velocidade_aumentada
    k = pygame.key.get_pressed()

    if not criado: 
        In = Enemy(2)
        In.add()
        criado = 1

    if  self.contadorinimigo >= 30*nivel:
        In.add()
        self.contadorinimigo = 0

    In.do(self.x,self.y)
    self.contadorinimigo += 1    

    t = Shoot(self.x+70, self.y+30, lista) 
    t.do()
    self.contadorshoot += 1

    score.collide(t.lista, In.lista_inimigo)
    life_h.collide(P, In.lista_inimigo)

    if k[K_a]: 
        self.xvel = - (self.vel + velocidade_aumentada)
        self.direcao = "esquerda"

    elif k[K_d]: 
        self.xvel = (self.vel + velocidade_aumentada)
        self.direcao = "direita"

    else: 
        self.xvel = 0
        self.direcao = "parado"

    if k[K_s]: 
        self.yvel = (self.vel + velocidade_aumentada)
        self.direcao = "baixo"

    elif k[K_w]: 
        self.yvel = - (self.vel + velocidade_aumentada)
        self.direcao = "cima"

    else: 
        self.yvel=0

    if k[K_SPACE]: 

        if self.contadorshoot >= 25:
            lista = t.add(self.x, self.y, self.para)
            self.contadorshoot = 0

def mover(self):
    self.rect.x = self.x
    self.rect.y = self.y
    self.x += self.xvel

    if self.x > display_width-200:
        self.x = display_width-200
    if self.x < 120:
        self.x = 120

    self.y += self.yvel

    if self.y > display_high - 200:
        self.y = display_high - 200
    if self.y < 120:
        self.y = 120

def image(self):
    global display

    self.count += 1
    if self.count > 3 :
        self.walkCount = (self.walkCount+1 ) % 6
        self.standCount = (self.standCount+1) % 5
        self.count = 0

    if self.direcao == "esquerda":

        wleft = pygame.transform.scale(walkRight[self.walkCount], (75, 80))
        display.blit(wleft, (self.x,self.y))
        self.para = "esq"

    if self.direcao == "direita":

        wleft = pygame.transform.scale(walkRight[self.walkCount], (75, 80))
        display.blit(pygame.transform.flip(wleft,True,False), (self.x,self.y))
        self.para = "dir"

    if self.direcao == "parado":    
        standing = pygame.transform.scale(st[self.standCount],(75,80))
        if self.para == "dir" or self.para == "centro":
            display.blit(pygame.transform.flip(standing,True,False), (self.x,self.y))
        elif self.para == "esq":
            display.blit(standing, (self.x,self.y))

    if self.direcao == "cima" or self.direcao == "baixo":
        up = pygame.transform.scale(walkRight[self.walkCount],(75,80))
        if self.para == "dir" or self.para == "centro":
            display.blit(pygame.transform.flip(up,True,False),(self.x,self.y))
        elif self.para == "esq":
            display.blit(up,(self.x,self.y))

def do(self):
    self.teclas()
    self.mover()
    self.image()

------------------CLASS ENEMIE----------------

class Enemy(pygame.sprite.Sprite): def init(self, vel): pygame.sprite.Sprite.init(self) self.vel = vel self.count = 0 self.walkCount = 0 self.lista_inimigo = [] self.cont = cont

def perseguir(self,xp,yp):

    for i in self.lista_inimigo:

        if xp > i[0]:
            i[0] += self.vel
            i[2] = "direita"
        if xp < i[0]:
            i[0] -= self.vel
            i[2] = "esquerda"
        if yp > i[1]:
            i[1] += self.vel
        if yp < i[1]:
            i[1] -= self.vel

def add(self):

        direcao = 'esquerda'
        randx = random.choice(range(200, 1100, 1))
        randy = random.choice(range(200, 500, 1))
        self.lista_inimigo.append([randx, randy, direcao])
        self.cont = 0
        return self.lista_inimigo

def destroy(self, el):

    self.el = el
    self.walkCountmorte = 0
    self.walkCountmorte = (self.walkCountmorte+1 ) % 7
    index = self.lista_inimigo.index(el)
    del (self.lista_inimigo[index])
    if self.walkCountmorte != 4:

        morte = pygame.transform.scale(caveiramorte[self.walkCountmorte],(90,90))
        display.blit(morte,(el[0] - 15, el[1]))

def destroyall(self):

    for el in self.lista_inimigo:
        index = self.lista_inimigo.index(el)
        del (self.lista_inimigo[index])

    for el in self.lista_inimigo:
        index = self.lista_inimigo.index(el)
        del (self.lista_inimigo[index])

def image(self):

    display1 = pygame.display.get_surface()
    self.count += 1

    if self.count > 2 :
        self.walkCount = (self.walkCount + 1 ) % 9
        self.count = 0

    for i in self.lista_inimigo:

        if i[2] == "direita":
            ene = pygame.transform.scale(en[self.walkCount], (60, 80))
            self.rect = ene.get_rect()
            self.rect.x = i[0]
            self.rect.y = i[1]
            display1.blit(ene, (i[0], i[1]))

        if i[2] == "esquerda":
            ene = pygame.transform.scale(en[self.walkCount], (60, 80))
            self.rect = ene.get_rect()
            self.rect.x = i[0]
            self.rect.y = i[1]
            display1.blit(pygame.transform.flip(ene,True,False), (i[0], i[1]))

def do(self, xp, yp):
    self.perseguir(xp,yp)
    self.image()

------------------CLASS SHOOT-----------------

class Shoot(pygame.sprite.Sprite):

def __init__(self, x, y, lista):
    pygame.sprite.Sprite.__init__(self)
    self.x = x
    self.y = y
    self.vel = 30
    self.lista = lista
    self.rect = tiro3.get_rect()

def mover(self):
    for x in self.lista:
        if x[0] >= 95 and x[0] <= 1245: 
            if x[2] == 'dir' or x[2] == 'centro':
                x[0] += self.vel
            if x[2] == 'esq':
                x[0] -= self.vel
        else:
            self.destroywalls(x[0], x[1], x)

def image(self):
    global display
    display = pygame.display.get_surface()

    for tiro in self.lista:

        self.rect.x = tiro[0]
        self.rect.y = tiro[1]

        if tiro[2] == 'dir' or tiro[2] == 'centro':
            display.blit(tiro3,(tiro[0]+25, tiro[1]))
        if tiro[2] == 'esq':
            display.blit(pygame.transform.flip(tiro3,True,False),(tiro[0] + 25, tiro[1]))

def destroywalls(self, x, y, el):
    self.x = x
    self.y = y
    self.el = el

    self.walkCountshot = 0
    self.walkCountshot = (self.walkCountshot + 1 ) % 3

    if self.walkCountshot != 2:
        index = self.lista.index(el)
        del (self.lista[index])
        pygame.time.wait(20)
        tiros = pygame.transform.scale(tirosumindo[self.walkCountshot],(60,55))
        display.blit(tiros,(x, y))

def destroyenemie(self, el):
    try:
        self.el = el
        index = self.lista.index(el)
        del (self.lista[index])

    except ValueError:
        pass

def add(self, x, y, para):
    self.x = x
    self.y = y
    self.para = para
    self.lista.append([self.x, self.y, para])
    return self.lista

def do(self):
    self.mover()
    self.image()

----------------CLASS COIN------------------

class Coin: def init(self, x, y): self.walkCount_coin = 0 self.x = x self.y = y self.count = 0 self.contador = 0 self.n = 1

def image(self):
    display = pygame.display.get_surface()
    self.count += 1
    score_texto = myfont.render('x ' + str(self.contador), 1, (255,255,0))

    if self.count > 2 :
        self.walkCount_coin = (self.walkCount_coin + 1 ) % 6
        self.count = 0

    coinsize = pygame.transform.scale(coin[self.walkCount_coin],(40,50))
    display.blit(coinsize,(self.x - 30,self.y))
    display.blit(score_texto, (self.x + 10, self.y - 14))

def collide(self, lista2, lista):
    for i in lista2:
        for el in lista:
           if i[0] in range(el[0], el[0] + 60) and i[1] in range(el[1], el[1] + 30):
                t.destroyenemie(i)
                In.destroy(el)
                self.contador += 1

                if self.contador == 10*self.n:
                    self.n += 1
                    life_h.add()

def do(self):
    self.image()

----------------CLASS LIFE------------------

class Life: def init(self, x, y): self.x = x self.y = y self.contador = 3

def image(self):
    Vida = myfont.render('x ' + str(self.contador), 1, (188, 0, 0))
    display = pygame.display.get_surface()
    display.blit(Vida,(90,5))
    display.blit(life_hearth,(self.x,self.y))

def add(self):
    self.contador += 1
    life_gain.set_volume(1)
    life_gain.play()
    self.image()

def delete(self):
    self.contador -= 1
    self.image()
    Life_one.play()

def collide(self, P, lista):
     for i in lista:
         if i[0] in range(P.x - 5, P.x + 65) and i[1] in range(P.y - 3, P.y + 60):
            In.destroy(i)
            self.delete()

def do(self):
    self.image()

-------------------------CLASS VIDA ALEAT-----------------

class Life_rdm: def init(self): self.lista_hearth = [] self.contadortempo = 0

def image(self):
    display = pygame.display.get_surface()

    for i in self.lista_hearth:
        display.blit(life_hearth, (i[0], i[1]))

def add(self):

    randx = random.choice(range(200, 1100, 1))
    randy = random.choice(range(200, 500, 1))
    self.lista_hearth.append([randx, randy])
    self.contadortempo = 0
    return self.lista_hearth

def collide(self):
    self.contadortempo += 1
    for i in self.lista_hearth:
        if i[0] in range(P.x - 10, P.x + 80) and i[1] in range(P.y - 10, P.y + 80):

            if life_h.contador >= 3:
                life_h.contador += 1

            if life_h.contador <3:
                life_h.contador = 3

            life_gain.play()
            index = self.lista_hearth.index(i)
            del (self.lista_hearth[index])  
            self.contadortempo = 0

        if self.contadortempo >= 400:
            try:
                index = self.lista_hearth.index(i)
                del (self.lista_hearth[index])   
                self.contadortempo = 0
            except ValueError:
                pass

def do(self):
    self.collide()
    self.image()

-------------------------CLASS MORTE ALEAT-----------------

class Morte_rdm: def init(self): self.lista_morte = [] self.contadortempo_m = 0

def image(self):
    display = pygame.display.get_surface()

    for i in self.lista_morte:
        display.blit(img_morte, (i[0], i[1]))

def add(self):

    randx = random.choice(range(200, 1100, 1))
    randy = random.choice(range(200, 500, 1))
    self.lista_morte.append([randx, randy])
    self.contadortempo_m = 0
    return self.lista_morte

def collide(self):
    self.contadortempo_m += 1
    for i in self.lista_morte:
        if i[0] in range(P.x - 10, P.x + 80) and i[1] in range(P.y - 10, P.y + 80):
            life_h.contador -= 3
            Life_one.play()
            index = self.lista_morte.index(i)
            del (self.lista_morte[index])  
            self.contadortempo_m = 0

        if self.contadortempo_m >= 900:
            try:
                index = self.lista_morte.index(i)
                del (self.lista_morte[index])   
                self.contadortempo_m = 0
            except ValueError:
                pass

def do(self):
    self.collide()
    self.image()

----------------------CLASS POTE DE OURO-----------------

class Ouro_rdm: def init(self): self.lista_Ouro = [] self.contadortempo_o = 0

def image(self):
    display = pygame.display.get_surface()

    for i in self.lista_Ouro:
        display.blit(pote_ouro, (i[0], i[1]))

def add(self):

    randx = random.choice(range(200, 1100, 1))
    randy = random.choice(range(200, 500, 1))
    self.lista_Ouro.append([randx, randy])
    self.contadortempo_o = 0
    return self.lista_Ouro

def collide(self):
    self.contadortempo_o += 1
    for i in self.lista_Ouro:
        if i[0] in range(P.x - 10, P.x + 80) and i[1] in range(P.y - 10, P.y + 80):

            score.contador += 20
            life_h.contador += 5
            index = self.lista_Ouro.index(i)
            del (self.lista_Ouro[index])  
            self.contadortempo_o = 0

        if self.contadortempo_o >= 300:
            try:
                index = self.lista_Ouro.index(i)
                del (self.lista_Ouro[index])   
                self.contadortempo_o = 0
            except ValueError:
                pass

def do(self):
    self.collide()
    self.image()

----------------------CLASS POTE DE OURO-----------------

class Nuke: def init(self): self.lista_Nuke = [] self.contadortempo_n = 0 self.contador_nuke = 1

def image(self):
    display = pygame.display.get_surface()

    nk = myfont.render('x ' + str(self.contador_nuke), 1, (127,255,0))
    display = pygame.display.get_surface()
    display.blit(nk,(700,5))
    display.blit(nuketown,(650,13))

    for i in self.lista_Nuke:
        display.blit(nuketown, (i[0], i[1]))

def add(self):

    randx = random.choice(range(200, 1100, 1))
    randy = random.choice(range(200, 500, 1))
    self.lista_Nuke.append([randx, randy])
    self.contadortempo_n = 0
    return self.lista_Nuke

def collide(self):
    self.contadortempo_n += 1
    for i in self.lista_Nuke:
        if i[0] in range(P.x - 10, P.x + 80) and i[1] in range(P.y - 10, P.y + 80) and self.contador_nuke == 0:

            self.contador_nuke += 1
            index = self.lista_Nuke.index(i)
            del (self.lista_Nuke[index])  
            self.contadortempo_n = 0

        if self.contadortempo_n >= 300:
            try:
                index = self.lista_Nuke.index(i)
                del (self.lista_Nuke[index])   
                self.contadortempo_n = 0
            except ValueError:
                pass

def teclas(self):

    k = pygame.key.get_pressed()
    if k[K_n] and self.contador_nuke > 0:
        atomicbomb.play()
        In.destroyall()
        self.contador_nuke -= 1

def do(self):
    self.collide()
    self.image()
    self.teclas()

----------------FUNCTION GAME----------------

def Game(): global ma, vida_aleat, morte_aleat, cria_v, cria_m, cria_o, o_aleat, n_aleat, cria_n

gameDisplay.blit(ma, (0, 0))

P.do()
score.do()
life_h.do()
N.do()

vida_aleat += 1
morte_aleat += 1
o_aleat += 1
n_aleat += 1

if n_aleat == 3500:
    n_aleat = 0
    N.add()
    cria_n = True

if cria_n:
    N.do()

if vida_aleat == 2000:
    vida_aleat = 0
    V.add()
    cria_v = True

if cria_v:
    V.do()

if morte_aleat == 4500:
    morte_aleat = 0
    M.add()
    cria_m = True

if cria_m:
    M.do()

if o_aleat == 4000:
    o_aleat = 0
    O.add()
    cria_o = True

if cria_o:
    O.do()

pygame.display.update()

-----------------FUNC GAME OVER---------------------

def Gameover(): Gameover = True while Gameover:

    if score.contador <= 50:
        score_texto = myfont.render('Você matou ' + str(score.contador) + ' caveiras', 1, (255, 255, 255))
        gameDisplay.blit(game_over, (0,0))
        gameDisplay.blit(score_texto, (300,300))
        pygame.mixer.music.load('Game Over sound effect.mp3')
        pygame.mixer.music.play(0)
        pygame.display.update()
        pygame.time.wait(7000)

    if 50 < score.contador <= 170:
        score_texto2 = myfont.render('Você matou ' + str(score.contador) + ' caveiras', 1, (0, 0, 0))
        gameDisplay.blit(game_over2, (0,0))
        gameDisplay.blit(score_texto2, (250,300))
        pygame.mixer.music.load('Game Over sound effect.mp3')
        pygame.mixer.music.play(0)
        pygame.display.update() 
        pygame.time.wait(7000)

    if 170 < score.contador:
        score_texto3 = myfont.render('Você matou ' + str(score.contador) + ' caveiras', 1, (255, 0, 0))
        gameDisplay.blit(game_over3, (0,0))
        gameDisplay.blit(score_texto3, (260,250))
        pygame.mixer.music.load('60.mp3')
        pygame.mixer.music.play(0)
        pygame.display.update() 
        pygame.time.wait(7000)

    Gameover = False

-------------------CREDITS-----------------

def credits_game():

global creditss, game, button, mapas, ajuda, song
pygame.mixer.music.load('Star Wars Music Theme.mp3')
pygame.mixer.music.play(-1)
y_c = 800
while creditss:
    y_c -= 2

    gameDisplay.blit(star_wars2,(0, 0))
    okay_group.draw(gameDisplay)
    gameDisplay.blit(text, (350, y_c))

    if pygame.mouse.get_pressed():
            if pygame.mouse.get_pressed()[0] == 1: 
                if pygame.mouse.get_pos()[0] in range(okayb.x[0],okayb.x[1]) and pygame.mouse.get_pos()[1] in range(okayb.y[0],okayb.y[1]):
                   creditss = False 
                   pygame.mixer.music.load('Mattashi - The Final Battle [Epic 8-Bit Orchestral Battle].mp3')
                   pygame.mixer.music.play(-1)
                   tela.blit(menu, (0,0))
                   buttonmusic.play()

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
           button = False
           mapas = False
           ajuda = False
           game = False
           creditss = False

    pygame.display.update()

--------------PAUSE--------------

def paused(): global game, pause, shopping while pause:

    gameDisplay.blit(TextSurf,(400,100))

    cont.draw(gameDisplay)

    if pygame.mouse.get_pressed():

        if pygame.mouse.get_pressed()[0] == 1:
            if pygame.mouse.get_pos()[0] in range(continueb.x[0],continueb.x[1]) and pygame.mouse.get_pos()[1] in range(continueb.y[0],continueb.y[1]):
                buttonmusic.play()
                unpause()
                pygame.time.wait(200)

            elif pygame.mouse.get_pos()[0] in range(quit2.x[0],quit2.x[1]) and pygame.mouse.get_pos()[1] in range(quit2.y[0],quit2.y[1]):
                game = False
                buttonmusic.play()
                pause = False

            elif pygame.mouse.get_pos()[0] in range(shopb.x[0],shopb.x[1]) and pygame.mouse.get_pos()[1] in range(shopb.y[0],shopb.y[1]):
                shopping = True
                buttonmusic.play()
                func_shopp()

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            game = False
            pause = False

    pygame.display.update()

def unpause(): global pause pause = False return pause

-----------------UGRADE--------------------

def func_shopp(): global game, pause, shopping, velocidade_aumentada, contador_de_shop_vida, contador_de_shop_velo, contador_de_shop_nuke

while shopping:
    score_textohe = myfont.render(str(contador_de_shop_vida*10) + ' moedas', 1, (244, 65, 65))
    score_textove = myfont.render(str(contador_de_shop_velo*20) + ' moedas', 1, (244, 145, 65))
    score_textonu = myfont.render(str(contador_de_shop_nuke*50) + ' moedas', 1, (65, 244, 131))

    score_textohe_cpmprao = myfont.render('Você comprou: ' + str(contador_de_shop_vida-1), 1, (244, 65, 65))
    score_textove_cpmprao = myfont.render('Você comprou: ' + str(contador_de_shop_velo-1), 1, (244, 145, 65))
    score_textonu_cpmprao = myfont.render('Você comprou: ' + str(contador_de_shop_nuke-1), 1, (65, 244, 131))
    score_texto_suamoeda = myfont.render('Sua moeda:  ' + str(score.contador), 1, (255,255,0))

    gameDisplay.blit(upgradeloja,(0,0))

    shop_but.draw(gameDisplay)

    gameDisplay.blit(score_textohe,(1100, 500))
    gameDisplay.blit(score_textove,(100, 500))
    gameDisplay.blit(score_textonu,(590, 500))

    gameDisplay.blit(score_textohe_cpmprao,(1030, 550))
    gameDisplay.blit(score_textove_cpmprao,(50, 550))
    gameDisplay.blit(score_textonu_cpmprao,(530, 550))
    gameDisplay.blit(score_texto_suamoeda,(1050, 30))

    gameDisplay.blit(life_hearth,(1156, 425))
    gameDisplay.blit(nuketown,(697, 426))
    gameDisplay.blit(seta_loja,(179, 433))

    if pygame.mouse.get_pressed():

        if pygame.mouse.get_pressed()[0] == 1:
            if pygame.mouse.get_pos()[0] in range(shop_but1.x[0],shop_but1.x[1]) and pygame.mouse.get_pos()[1] in range(shop_but1.y[0],shop_but1.y[1]) and score.contador >= 10*contador_de_shop_vida:
                life_h.contador += 1
                score.contador -= 10*contador_de_shop_vida
                contador_de_shop_vida += 1
                buttonmusic.play()

            elif pygame.mouse.get_pos()[0] in range(shop_but2.x[0],shop_but2.x[1]) and pygame.mouse.get_pos()[1] in range(shop_but2.y[0],shop_but2.y[1]) and score.contador >= 20*contador_de_shop_velo:
                velocidade_aumentada += 2
                score.contador -= 10*contador_de_shop_velo
                contador_de_shop_velo += 1
                buttonmusic.play()

            elif pygame.mouse.get_pos()[0] in range(shop_but3.x[0],shop_but3.x[1]) and pygame.mouse.get_pos()[1] in range(shop_but3.y[0],shop_but3.y[1]) and score.contador >= 50*contador_de_shop_nuke and N.contador_nuke == 0:
                N.contador_nuke += 1
                score.contador -= 10*contador_de_shop_nuke
                contador_de_shop_nuke += 1
                buttonmusic.play()

            elif pygame.mouse.get_pos()[0] in range(okayb3.x[0],okayb3.x[1]) and pygame.mouse.get_pos()[1] in range(okayb3.y[0],okayb3.y[1]):
                shopping = False
                pause = False
                buttonmusic.play()
                pygame.time.wait(1000)

    if pygame.key.get_pressed()[K_ESCAPE]:
        shopping = False
        pause = False
        buttonmusic.play()
        pygame.time.wait(1000)

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            game = False
            shopping = False
            pause = False

    pygame.display.update()

--------------AJUDA--------------

def help_function(): global game, helpi1, helpi2, mapas, button

while helpi1:
    gameDisplay.blit(help_1,(0, 0))
    helpbu.draw(gameDisplay)

    if pygame.mouse.get_pressed():

        if pygame.mouse.get_pressed()[0] == 1:
            if pygame.mouse.get_pos()[0] in range(okayb2.x[0],okayb2.x[1]) and pygame.mouse.get_pos()[1] in range(okayb2.y[0],okayb2.y[1]):
                helpi1 = False
                helpi2 = False
                tela.blit(menu, (0,0))
                buttonmusic.play()

            elif pygame.mouse.get_pos()[0] in range(f.x[0],f.x[1]) and pygame.mouse.get_pos()[1] in range(f.y[0],f.y[1]):
                helpi2 = True
                helpi1 = False
                buttonmusic.play()

    pygame.display.update()

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            game = False
            helpi1 = False
            helpi2 = False
            button = False
            mapas = False

while helpi2:
    gameDisplay.blit(menu_ajuda,(0, 0))
    helpbu2.draw(gameDisplay)

    if pygame.mouse.get_pressed():

        if pygame.mouse.get_pressed()[0] == 1:
            if pygame.mouse.get_pos()[0] in range(okayb2.x[0],okayb2.x[1]) and pygame.mouse.get_pos()[1] in range(okayb2.y[0],okayb2.y[1]):
                helpi2 = False
                tela.blit(menu, (0,0))
                buttonmusic.play()

    pygame.display.update()

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            game = False
            helpi2 = False
            button = False
            mapas = False

------------------BUTTONS-----------------

create button

pygame.display.set_caption('Menu') map1b = Button(map1,160, 550) map2b = Button(map2,630, 550) map3b = Button(map3,1080, 550) playb = Button(play,100,360) quitb = Button(Quit,450,350) quit2 = Button(Quit,800,350) creditsb = Button(Credits,1100, 600) continueb = Button(continuegame, 450, 350) okayb = Button(okay, 50, 700) okayb2 = Button(okay, 30, 730) okayb3 = Button(okay, 30, 730) help_i = Button(help_inicial, 300, 500) f = Button(foward, 1000, 650) f2 = Button(foward, 1000, 650) shopb = Button(shop, 630, 500) shop_but1 = Button(shop_heart, 1120, 400) shop_but2 = Button(shop_velo, 150, 400) shop_but3 = Button(shop_nuke, 650, 400)

add

buttong.add(playb) buttong.add(quitb) buttong.add(creditsb) buttong.add(help_i)

mapbut.add(map1b) mapbut.add(map2b) mapbut.add(map3b)

cont.add(continueb) cont.add(quit2) cont.add(shopb)

okay_group.add(okayb)

helpbu.add(okayb2) helpbu.add(f)

helpbu2.add(okayb2)

shop_but.add(shop_but1) shop_but.add(shop_but2) shop_but.add(shop_but3) shop_but.add(okayb3)

-----------------LOOP BUTTON-------------------

tela = pygame.display.set_mode((display_width,display_high),0,32) tela.blit(menu, (0,0))

pygame.mixer.music.load('Mattashi - The Final Battle [Epic 8-Bit Orchestral Battle].mp3') pygame.mixer.music.play(-1)

while button:

mousepos = pygame.mouse.get_pos()
buttong.draw(tela)

if pygame.mouse.get_pressed():

    if pygame.mouse.get_pressed()[0] == 1:
        click = False
        sair = False

        if mousepos[0] in range(playb.x[0],playb.x[1]) and mousepos[1] in range(playb.y[0],playb.y[1]):
            click = True
            mapas = True

        elif mousepos[0] in range(help_i.x[0],help_i.x[1]) and mousepos[1] in range(help_i.y[0],help_i.y[1]):
            buttonmusic.play()
            pygame.time.wait(20)
            helpi1 = True
            help_function()

        elif mousepos[0] in range(creditsb.x[0],creditsb.x[1]) and mousepos[1] in range(creditsb.y[0],creditsb.y[1]):
            buttonmusic.play()
            pygame.time.wait(20)
            creditss = True
            credits_game()

        elif mousepos[0] in range(quitb.x[0],quitb.x[1]) and mousepos[1] in range(quitb.y[0],quitb.y[1]):
            mapas = False
            ajuda = False
            game = False
            click = True

        if click:
            buttonmusic.play()
            pygame.time.wait(20)
            button = False

for event in pygame.event.get():
    if event.type == pygame.QUIT:
        button = False
        mapas = False
        ajuda = False
        game = False

pygame.display.update()

---------------------LOOP MAPAS--------------------

tela2 = pygame.display.set_mode((display_width,display_high),0,32) tela2.blit(MENU, (0,0))

while mapas:

global mp

mousepos = pygame.mouse.get_pos()
mapbut.draw(tela)
pygame.display.update()

if pygame.mouse.get_pressed():
    if pygame.mouse.get_pressed()[0] == 1:
        click=False

        if mousepos[0] in range(map1b.x[0],map1b.x[1]) and mousepos[1] in range(map1b.y[0],map1b.y[1]):
            click = True
            mp = 'B-kcEgfUIAAhvcv - Copia.png'
            song  = '8-Bit Boss Battle 4 - By EliteFerrex.mp3'
            nivel = 3

        elif mousepos[0] in range(map2b.x[0],map2b.x[1]) and mousepos[1] in range(map2b.y[0],map2b.y[1]):
            click = True
            mp = 'm56cs5t.png'
            song  = 'At Dooms Gate (E1M1) 8 Bit Remix - Doom.wav'
            nivel = 2

        elif mousepos[0] in range(map3b.x[0],map3b.x[1]) and mousepos[1] in range(map3b.y[0],map3b.y[1]):
            click = True
            mp = 'binding_of_isaac_rebirth_tiles_by_wanyo-da3j2bf - Copia.png'
            song = 'Megalovania - Undertale (8 Bit Universe Version).mp3'
            nivel = 1

        if click:
            buttonmusic.play()
            pygame.time.wait(20)
            mapas = False
            game = True
            bg = pygame.image.load(mp).convert()
            ma = pygame.transform.scale(bg, (display_width, display_high))
            pygame.mixer.music.load(song)
            pygame.mixer.music.play(-1)

for event in pygame.event.get():
    if event.type == pygame.QUIT:
        mapas = False
        game = False      

----------------------LOOP DO GAME-----------------------

P = Player(7) P.marcarlocal(200,500)

score = Coin(1300,20) life_h = Life(20,10)

V = Life_rdm() vida_aleat = 0

M = Morte_rdm() morte_aleat = 0

O = Ouro_rdm() o_aleat = 0

N = Nuke() n_aleat = 0

while game and not sair:

for event in pygame.event.get():     

    if event.type == pygame.QUIT:
        game = False
    if pygame.key.get_pressed()[K_ESCAPE]:
        pause = True
        paused()

Game()     

if life_h.contador <= 0:
    Gameover()
    game = False

CLOCK.tick(FPS)

-----------------QUIT------------------

print('Saindo') pygame.quit()