From 6387992312f01e5e1f7ce0e1666cd92f07fe292b Mon Sep 17 00:00:00 2001 From: Kaio Henrique Date: Thu, 28 Nov 2024 11:48:58 -0300 Subject: [PATCH] Test Single Player --- Naval Battle/NavalBattle.py | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/Naval Battle/NavalBattle.py b/Naval Battle/NavalBattle.py index 908354a..f8ca52e 100644 --- a/Naval Battle/NavalBattle.py +++ b/Naval Battle/NavalBattle.py @@ -36,6 +36,7 @@ tiro_pos = { "E3": (-200,0), "E4": (-200,-100), "E5": (-200,-200), + "QUIT": (1000, 1000), } #funções @@ -90,17 +91,17 @@ if gmode == "single": #Player 1 p1 = tl.Turtle() p1.up() - spawnp1 = str(input("Senhor, Onde Nosso Submarino Deve Ficar? ")) + spawnp1 = "A1" #str(input("Senhor, Onde Nosso Submarino Deve Ficar? ")) p1.goto(tiro_pos[spawnp1]) p2 = tl.Turtle() p2.up() - spawnp2 = str(input("Senhor, Onde Nosso Crusador Deve Ficar? ")) + spawnp2 = "A2" #str(input("Senhor, Onde Nosso Crusador Deve Ficar? ")) p2.goto(tiro_pos[spawnp2]) p3 = tl.Turtle() p3.up() - spawnp3 = str(input("Senhor, Onde Nosso Destroyer Deve Ficar? ")) + spawnp3 = "A3" #str(input("Senhor, Onde Nosso Destroyer Deve Ficar? ")) p3.goto(tiro_pos[spawnp3]) #pass @@ -127,17 +128,11 @@ if gmode == "single": e3.goto(random.choice(posx), random.choice(posy)) if e2.pos() == e3.pos(): e3.goto(random.choice(posx), random.choice(posy)) - #pass - #vencer - if win == True: - tl.Terminator() - - + #pass while win == False: - tiro = tl.textinput("linha X do disparo","Em qual quadrante X devemos disparar a artilharia") - #vencer - if win == True: - break + tiro = tl.textinput("Onde Devemos Disparar?","Em Qual Intersecão Devemos Disparar?\nDigite (quit) Para Sair").upper() + while tiro not in tiro_pos: + tiro = tl.textinput("linha X do disparo","Em qual quadrante X devemos disparar a artilharia") #acerto Submarino if (tiro_pos[tiro]) == e1.pos(): bullet.showturtle() @@ -169,12 +164,13 @@ if gmode == "single": print("errou!") bullet.write("Erramos o alvo\n Capitão!",False,align="center") bullet.hideturtle() - - #erro - if e1.pos() not in tiro_pos and e2.pos() not in tiro_pos and e3.pos() not in tiro_pos: - win = True + #vencer + if (e1.pos() == (-1000, -1000)) and (e2.pos() == (-1000, -1000)) and (e3.pos() == (-1000, -1000)): print("voçe ganhou") - + break + #sair + if bullet.pos() == (1000, 1000): + break