def quarto(visited_basement, visited_garden): done = False keyS = False space = False global ponto wall1 = Wall(0, 437, 177, 63) wall_list.add(wall1) wall2 = Wall(557, 291, 146, 4) wall_list.add(wall2) wall3 = Wall(683, 308, 20, 151) wall_list.add(wall3) wall4 = Wall(566, 390, 138, 69) wall_list.add(wall4) wall5 = Wall(269, 437, 476, 62) wall_list.add(wall5) wall6 = Wall(177, 481, 92, 19) wall_list.add(wall6) wall7 = Wall(703, 285, 97, 215) wall_list.add(wall7) wall8 = Wall(768, 218, 22, 67) wall_list.add(wall8) wall9 = Wall(0, 0, 800, 145) wall_list.add(wall9) wall10 = Wall(319, 138, 128, 83) wall_list.add(wall10) wall11 = Wall(63, 122, 124, 64) wall_list.add(wall11) wall12 = Wall(0, 124, 63, 385) wall_list.add(wall12) wall13 = Wall(177, 481, 92, 19) wall_list.add(wall13) wall14 = Wall(703, 285, 97, 215) wall_list.add(wall14) wall15 = Wall(768, 218, 22, 67) wall_list.add(wall15) wall16 = Wall(0, 0, 800, 145) wall_list.add(wall16) wall17 = Wall(319, 138, 128, 83) wall_list.add(wall17) wall18 = Wall(63, 122, 124, 64) wall_list.add(wall18) wall19 = Wall(703, 138, 97, 62) wall_list.add(wall19) wall20 = Wall(63, 412, 60, 24) wall_list.add(wall20) bg_quarto = pygame.image.load("images/quarto.png") bg_quarto = pygame.transform.scale(bg_quarto, (800, 500)) leaf = pygame.image.load("images/galho_quarto.png") leaf = pygame.transform.scale(leaf, (60, 46)) galho = Wall(63, 373, 60, 46) galho.carregarImagem(leaf) all_sprite_list.add(galho) porta_porao = Interagivel( 564, 358, 139, 145, ["Uma escada leva a um estranho porao.Descer?", "S/N"]) screen.fill(BLACK) porta_jardim = Interagivel(770, 250, 20, 100, ["A saida leva para um lago,sair?", "S/N"]) if visited_basement: player.rect.x = 464 player.rect.y = 260 if visited_garden: player.rect.x = 464 player.rect.y = 260 while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True quit() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: player.changespeed(-5, 0) elif event.key == pygame.K_RIGHT: player.changespeed(5, 0) elif event.key == pygame.K_UP: player.changespeed(0, -5) elif event.key == pygame.K_DOWN: player.changespeed(0, 5) if event.key == pygame.K_s: keyS = True elif event.type == pygame.KEYUP: if event.key == pygame.K_LEFT: player.changespeed(5, 0) elif event.key == pygame.K_RIGHT: player.changespeed(-5, 0) elif event.key == pygame.K_UP: player.changespeed(0, 5) elif event.key == pygame.K_DOWN: player.changespeed(0, -5) if event.key == pygame.K_s: keyS = False keyset = [keyS, space] #transição para porão if porta_porao.sayhi(player, textbox, fonte) and keyset[0]: wall_list.remove(wall1) wall_list.remove(wall2) wall_list.remove(wall3) wall_list.remove(wall4) wall_list.remove(wall5) wall_list.remove(wall6) wall_list.remove(wall7) wall_list.remove(wall8) wall_list.remove(wall9) wall_list.remove(wall10) wall_list.remove(wall11) wall_list.remove(wall12) wall_list.remove(wall13) wall_list.remove(wall14) wall_list.remove(wall15) wall_list.remove(wall16) wall_list.remove(wall17) wall_list.remove(wall18) wall_list.remove(wall19) wall_list.remove(wall20) all_sprite_list.remove(galho) porao(visited_basement, chave_final) #transição para jardim if porta_jardim.sayhi(player, textbox, fonte) and keyset[0]: wall_list.remove(wall1) wall_list.remove(wall2) wall_list.remove(wall3) wall_list.remove(wall4) wall_list.remove(wall5) wall_list.remove(wall6) wall_list.remove(wall7) wall_list.remove(wall8) wall_list.remove(wall9) wall_list.remove(wall10) wall_list.remove(wall11) wall_list.remove(wall12) wall_list.remove(wall13) wall_list.remove(wall14) wall_list.remove(wall15) wall_list.remove(wall16) wall_list.remove(wall17) wall_list.remove(wall18) wall_list.remove(wall19) wall_list.remove(wall20) all_sprite_list.remove(galho) jardim(visited_garden, inv_machado, inv_peixe, inv_dinheiro, inv_comida, secret_path) screen.blit(bg_quarto, (0, 0)) all_sprite_list.update() all_sprite_list.draw(screen) textbox.image.fill(BLUE) texto('Tempo: ' + str(int(ponto)), WHITE, 30, 500, 565) ponto -= 0.0165 if ponto <= 0: game_over() pygame.display.flip() clock.tick(60)
def porao(visited_basement, chave_final): done = False keyS = False space = False global ponto player.rect.x = 100 player.rect.y = 30 escada_quarto = Interagivel(135, 60, 665, 100, ["Subir para o quarto?", "S/N"]) bg_basement = pygame.image.load("images/FasePorao.png") wall1 = Wall(180, 170, 10, 10) wall_list.add(wall1) wall2 = Wall(450, 100, 790, 10) wall_list.add(wall2) wall3 = Wall(380, 0, 10, 110) wall_list.add(wall3) wall4 = Wall(230, 150, 10, 10) wall_list.add(wall4) wall5 = Wall(280, 130, 10, 10) wall_list.add(wall5) wall6 = Wall(320, 110, 10, 10) wall_list.add(wall6) box = pygame.image.load("images/box.png") box = pygame.transform.scale(box, (100, 100)) box1 = Wall(0, 400, 100, 100) box1.carregarImagem(box) wall_list.add(box1) all_sprite_list.add(box1) box2 = Wall(0, 300, 100, 100) box2.carregarImagem(box) wall_list.add(box2) all_sprite_list.add(box2) box3 = Wall(200, 400, 100, 100) box3.carregarImagem(box) wall_list.add(box3) all_sprite_list.add(box3) box4 = Wall(200, 300, 100, 100) box4.carregarImagem(box) wall_list.add(box4) all_sprite_list.add(box4) realbox = Interagivel(100, 400, 100, 100, [ "Todas as caixas estao empoeiradas,mas um estranho brilho vem do fundo", "Tentar pegar o objeto?", "S/N" ]) realbox.carregarImagem(box) wall_list.add(realbox) all_sprite_list.add(realbox) while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True quit() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: player.changespeed(-5, 0) elif event.key == pygame.K_RIGHT: player.changespeed(5, 0) elif event.key == pygame.K_UP: player.changespeed(0, -5) elif event.key == pygame.K_DOWN: player.changespeed(0, 5) if event.key == pygame.K_s: keyS = True if event.key == pygame.K_n: keyn = True elif event.type == pygame.KEYUP: if event.key == pygame.K_LEFT: player.changespeed(5, 0) elif event.key == pygame.K_RIGHT: player.changespeed(-5, 0) elif event.key == pygame.K_UP: player.changespeed(0, 5) elif event.key == pygame.K_DOWN: player.changespeed(0, -5) if event.key == pygame.K_s: keyS = False keyset = [keyS, space] all_sprite_list.update() if escada_quarto.sayhi(player, textbox, fonte) and keyset[0]: visited_basement = True wall_list.remove(wall1) wall_list.remove(wall2) wall_list.remove(wall3) wall_list.remove(wall4) wall_list.remove(wall5) wall_list.remove(wall6) wall_list.remove(box1) wall_list.remove(box2) wall_list.remove(box3) wall_list.remove(box4) wall_list.remove(realbox) all_sprite_list.remove(box1) all_sprite_list.remove(box2) all_sprite_list.remove(box3) all_sprite_list.remove(box4) all_sprite_list.remove(realbox) quarto(visited_basement, visited_garden) if realbox.sayhi(player, textbox, fonte) and keyset[0]: chave_final = True player.key = True if chave_final: key = pygame.image.load("images/da_key.png") key = pygame.transform.scale(key, (40, 30)) keyfinal = Wall(700, 560, 40, 30) keyfinal.carregarImagem(key) all_sprite_list.add(keyfinal) screen.blit(bg_basement, (0, 0)) all_sprite_list.draw(screen) textbox.image.fill(BLUE) texto('Tempo: ' + str(int(ponto)), WHITE, 30, 500, 565) ponto -= 0.0165 pygame.display.flip() clock.tick(60)
def jardim(visited_garden, inv_machado, inv_peixe, inv_dinheiro, inv_comida, secret_path): done = False keyS = False space = False global ponto if player.secret == True: secret_path = True player.rect.x = 25 player.rect.y = 300 rock = Wall(0, 0, 800, 90) wall_list.add(rock) water = Wall(415, 0, 270, 250) wall_list.add(water) tree = Wall(75, 0, 50, 250) wall_list.add(tree) dog_house = Wall(295, 185, 100, 20) wall_list.add(dog_house) water2 = Wall(415, 400, 270, 250) wall_list.add(water2) img_fish = pygame.image.load("images/fish.png") img_fish = pygame.transform.scale(img_fish, (50, 50)) fish = Wall(700, 500, 50, 50) fish.carregarImagem(img_fish) bg_lake = pygame.image.load("images/FaseLago.png") porta_quarto = Interagivel(10, 440, 20, 60, ["Entrar no quarto?", "S/N"]) path_mirror = Interagivel( 770, 400, 20, 100, ["Uma porta para uma sala estranha.", "continuar?", "S/N"]) img_axe = pygame.image.load("images/axe.png") img_axe = pygame.transform.scale(img_axe, (50, 50)) axe = Interagivel(80, 250, 50, 50, ["Um machado velho esta preso na arvore. Pegar?", "S/N"]) axe.carregarImagem(img_axe) fishing_rod = Interagivel(685, 200, 60, 60, [ "Uma vara de pescar, talvez consiga um bom peixe se pescar.", "pescar?", "S/N" ]) img_rod = pygame.image.load("images/fishingrod.png") img_rod = pygame.transform.scale(img_rod, (60, 60)) fishing_rod.carregarImagem(img_rod) all_sprite_list.add(fishing_rod) secret_tunnel = Interagivel(135, 90, 100, 50, [ "Esse tunel te trouxe da floresta,e pode te levar de volta", "avancar para a floresta?", "S/N" ]) if secret_path: player.rect.x = 135 player.rect.y = 190 img_chain = pygame.image.load("images/chain.png") img_chain = pygame.transform.scale(img_chain, (32, 100)) chain = Interagivel(415, 300, 32, 150, [ "Um cadeado bloqueia seu caminho, talvez consiga quebra-lo com o machado", "quebrar o cadeado?(isso quebra o machado)", "S/N" ]) chain.carregarImagem(img_chain) all_sprite_list.add(chain) broke = False while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True quit() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: player.changespeed(-5, 0) elif event.key == pygame.K_RIGHT: player.changespeed(5, 0) elif event.key == pygame.K_UP: player.changespeed(0, -5) elif event.key == pygame.K_DOWN: player.changespeed(0, 5) if event.key == pygame.K_s: keyS = True elif event.type == pygame.KEYUP: if event.key == pygame.K_LEFT: player.changespeed(5, 0) elif event.key == pygame.K_RIGHT: player.changespeed(-5, 0) elif event.key == pygame.K_UP: player.changespeed(0, 5) elif event.key == pygame.K_DOWN: player.changespeed(0, -5) if event.key == pygame.K_s: keyS = False keyset = [keyS, space] all_sprite_list.update() if fishing_rod.sayhi(player, textbox, fonte) and keyset[0]: inv_peixe = True if inv_peixe: all_sprite_list.add(fish) else: all_sprite_list.remove(fish) #transição para quarto if porta_quarto.sayhi(player, textbox, fonte) and keyset[0]: all_sprite_list.remove(porta_quarto) all_sprite_list.remove(path_mirror) wall_list.remove(water) wall_list.remove(water2) wall_list.remove(rock) wall_list.remove(dog_house) wall_list.remove(tree) wall_list.remove(chain) if not inv_machado: all_sprite_list.remove(axe) all_sprite_list.remove(fishing_rod) all_sprite_list.remove(chain) visited_garden = True quarto(visited_basement, visited_garden) #transição para labirinto screen.blit(bg_lake, (0, 0)) if path_mirror.sayhi(player, textbox, fonte) and keyset[0]: wall_list.remove(water) wall_list.remove(water2) wall_list.remove(rock) wall_list.remove(dog_house) wall_list.remove(tree) all_sprite_list.empty() transition_in(inv_peixe, inv_dinheiro, inv_comida, chave_final) #tunel *super* secreto if secret_path: if secret_tunnel.sayhi(player, textbox, fonte) and keyset[0]: all_sprite_list.remove(porta_quarto) all_sprite_list.remove(path_mirror) wall_list.remove(water) wall_list.remove(water2) wall_list.remove(rock) wall_list.remove(dog_house) wall_list.remove(tree) all_sprite_list.remove(fishing_rod) all_sprite_list.remove(fish) all_sprite_list.remove(chain) final_room(inv_peixe, inv_dinheiro, inv_comida, chave_final, secret_path) else: if not broke: all_sprite_list.add(axe) wall_list.add(chain) all_sprite_list.add(chain) if chain.sayhi(player, textbox, fonte) and keyset[0]: if inv_machado: broke = True all_sprite_list.remove(chain) all_sprite_list.remove(axe) wall_list.remove(chain) if inv_machado: axe.rect.x = 650 axe.rect.y = 500 else: axe.rect.x = 80 axe.rect.y = 250 if axe.sayhi(player, textbox, fonte) and keyset[0]: inv_machado = True all_sprite_list.draw(screen) textbox.image.fill(BLUE) texto('Tempo: ' + str(int(ponto)), WHITE, 30, 500, 565) ponto -= 0.0165 if ponto <= 0: game_over() pygame.display.flip() clock.tick(60)
def final_room(inv_peixe, inv_dinheiro, inv_comida, chave_final, secret_path): done = False keyS = False space = False player.rect.x = 200 player.rect.y = 32 gateopen = False all_sprite_list.add(player) all_sprite_list.add(textbox) global ponto bg_finalC = pygame.image.load("images/background_closed_final.png") bg_finalC = pygame.transform.scale(bg_finalC, (800, 600)) bg_finalO = pygame.image.load("images/background_open_final.png") bg_finalO = pygame.transform.scale(bg_finalO, (800, 600)) img_background = pygame.image.load("images/galho_arvore1_final.png") img_background = pygame.transform.scale(img_background, (105, 104)) background = Interagivel(60, 329, 105, 104, [""]) background.carregarImagem(img_background) all_sprite_list.add(background) tun_img = pygame.image.load('images/door_open.png') tun_img = pygame.transform.scale(tun_img, (100, 100)) secret_tunnel = Interagivel(0, 243, 100, 100, [ "Esse tunel segue na direcao da casa", "se voce passar pelo tunel o cachorro voltara ao seu posto,prosseguir?", "S/N" ]) secret_tunnel.carregarImagem(tun_img) all_sprite_list.add(secret_tunnel) wall_list.add(secret_tunnel) img_npc1 = pygame.image.load("images/fishyboi.png") img_npc1 = pygame.transform.scale(img_npc1, (100, 100)) fish_npc = Interagivel(100, 0, 100, 100, [ "Se me der um bom peixe eu te pagarei bem.", "vender o peixe?", "S/N" ]) fish_npc.carregarImagem(img_npc1) all_sprite_list.add(fish_npc) wall_list.add(fish_npc) img_npc2 = pygame.image.load("images/oldman.png") img_npc2 = pygame.transform.scale(img_npc2, (100, 100)) food_npc = Interagivel(340, 30, 100, 100, [ "Um vendedor de racao.", "Se tiver dinheiro,talvez possa alimentar o cachorro feroz. Comprar?", "S/N" ]) food_npc.carregarImagem(img_npc2) wall_list.add(food_npc) all_sprite_list.add(food_npc) img_doge = pygame.image.load("images/dog_btw.png") img_doge = pygame.transform.scale(img_doge, (80, 80)) dog = Interagivel(300, 220, 80, 80, [ "Um cachorro feroz bloqueia seu caminho.Se tivesse comida,poderia disrtai-lo", "Dar comida ao cachorro?", "S/N" ]) dog.carregarImagem(img_doge) all_sprite_list.add(dog) wall_list.add(dog) gate = Interagivel(397, 193, 15, 151, [ "Um portao que necessita de uma chave, talvez voce tenha que procura-la", "Abrir o portao?(chave necessaria)", "S/N" ]) wall_list.add(gate) all_sprite_list.add(gate) wall = Wall(426, 10, 22, 169) wall_list.add(wall) all_sprite_list.add(wall) wall = Wall(192, 207, 27, 10) wall_list.add(wall) all_sprite_list.add(wall) wall = Wall(65, 108, 94, 73) wall_list.add(wall) all_sprite_list.add(wall) wall = Wall(397, 207, 53, 45) wall_list.add(wall) all_sprite_list.add(wall) wall = Wall(10, 180, 184, 15) wall_list.add(wall) all_sprite_list.add(wall) wall = Wall(10, 343, 787, 54) wall_list.add(wall) all_sprite_list.add(wall) wall = Wall(349, 179, 442, 15) wall_list.add(wall) all_sprite_list.add(wall) wall = Wall(393, 393, 53, 101) wall_list.add(wall) all_sprite_list.add(wall) fish = Wall(700, 500, 50, 50) img_fish = pygame.image.load("images/fish.png") img_fish = pygame.transform.scale(img_fish, (50, 50)) fish.carregarImagem(img_fish) img_food = pygame.image.load("images/dog_food.png") img_food = pygame.transform.scale(img_food, (40, 40)) food_icon = Wall(740, 550, 40, 40) food_icon.carregarImagem(img_food) moni = pygame.image.load("images/moni.png") moni = pygame.transform.scale(moni, (40, 40)) money_icon = Wall(740, 550, 40, 40) money_icon.carregarImagem(moni) key = pygame.image.load("images/da_key.png") key = pygame.transform.scale(key, (40, 30)) keyfinal = Wall(690, 550, 40, 30) keyfinal.carregarImagem(key) doggo = True if player.key == True: chave_final = True while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True quit() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: player.changespeed(-5, 0) elif event.key == pygame.K_RIGHT: player.changespeed(5, 0) elif event.key == pygame.K_UP: player.changespeed(0, -5) elif event.key == pygame.K_DOWN: player.changespeed(0, 5) if event.key == pygame.K_s: keyS = True elif event.type == pygame.KEYUP: if event.key == pygame.K_LEFT: player.changespeed(5, 0) elif event.key == pygame.K_RIGHT: player.changespeed(-5, 0) elif event.key == pygame.K_UP: player.changespeed(0, 5) elif event.key == pygame.K_DOWN: player.changespeed(0, -5) if event.key == pygame.K_s: keyS = False keyset = [keyS, space] if chave_final: all_sprite_list.add(keyfinal) if inv_peixe == True: all_sprite_list.add(fish) else: all_sprite_list.remove(fish) if inv_comida: all_sprite_list.add(food_icon) else: all_sprite_list.remove(food_icon) if inv_dinheiro: all_sprite_list.add(money_icon) else: all_sprite_list.remove(money_icon) if gate.sayhi(player, textbox, fonte) and keyset[0]: if chave_final: wall_list.remove(gate) bg_finalC = bg_finalO gate.text = [""] all_sprite_list.remove(gate) if inv_peixe: if fish_npc.sayhi(player, textbox, fonte) and keyset[0]: inv_dinheiro = True inv_peixe = False if inv_dinheiro: if food_npc.sayhi(player, textbox, fonte) and keyset[0]: inv_comida = True inv_dinheiro = False if inv_comida: if dog.sayhi(player, textbox, fonte) and keyset[0]: all_sprite_list.remove(dog) wall_list.remove(dog) dog.text = [""] inv_comida = False player.passe = True if secret_tunnel.sayhi(player, textbox, fonte) and keyset[0]: wall_list.empty() wall_list.add(textbox) all_sprite_list.remove(dog) all_sprite_list.remove(fish_npc) all_sprite_list.remove(food_npc) all_sprite_list.remove(secret_tunnel) all_sprite_list.remove(background) jardim(visited_garden, inv_machado, inv_peixe, inv_dinheiro, inv_comida, secret_path) finish = Interagivel(700, 0, 100, 600, ['']) all_sprite_list.update() screen.blit(bg_finalC, (0, 0)) secret_path = True player.secret = True all_sprite_list.draw(screen) textbox.image.fill(BLUE) texto('Tempo: ' + str(int(ponto)), WHITE, 30, 500, 565) ponto -= 0.0165 if ponto <= 0: game_over() pygame.display.flip() if finish.sayhi(player, textbox, fonte): all_sprite_list.empty() wall_list.empty() end_screen() clock.tick(60)