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)]
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
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()
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)
-- 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):
------------------CLASS PLAYER-------------------
class Player(pygame.sprite.Sprite):
------------------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
------------------CLASS SHOOT-----------------
class Shoot(pygame.sprite.Sprite):
----------------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
----------------CLASS LIFE------------------
class Life: def init(self, x, y): self.x = x self.y = y self.contador = 3
-------------------------CLASS VIDA ALEAT-----------------
class Life_rdm: def init(self): self.lista_hearth = [] self.contadortempo = 0
-------------------------CLASS MORTE ALEAT-----------------
class Morte_rdm: def init(self): self.lista_morte = [] self.contadortempo_m = 0
----------------------CLASS POTE DE OURO-----------------
class Ouro_rdm: def init(self): self.lista_Ouro = [] self.contadortempo_o = 0
----------------------CLASS POTE DE OURO-----------------
class Nuke: def init(self): self.lista_Nuke = [] self.contadortempo_n = 0 self.contador_nuke = 1
----------------FUNCTION GAME----------------
def Game(): global ma, vida_aleat, morte_aleat, cria_v, cria_m, cria_o, o_aleat, n_aleat, cria_n
-----------------FUNC GAME OVER---------------------
def Gameover(): Gameover = True while Gameover:
-------------------CREDITS-----------------
def credits_game():
--------------PAUSE--------------
def paused(): global game, pause, shopping while pause:
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
--------------AJUDA--------------
def help_function(): global game, helpi1, helpi2, mapas, button
------------------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:
---------------------LOOP MAPAS--------------------
tela2 = pygame.display.set_mode((display_width,display_high),0,32) tela2.blit(MENU, (0,0))
while mapas:
----------------------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:
-----------------QUIT------------------
print('Saindo') pygame.quit()