Limpar indentação

This commit is contained in:
Guilherme Aleixo de Oliveira Martins 2024-11-21 13:28:29 -03:00
parent 954a9524a8
commit c900d39454
1 changed files with 33 additions and 52 deletions

View File

@ -4,24 +4,28 @@ import random
posx = [-200, -100, 0, 100, 200] posx = [-200, -100, 0, 100, 200]
posy = [-200, -100, 0, 100, 200] posy = [-200, -100, 0, 100, 200]
postiro = ['-200 -200', '-200 -100', '-200 0', '-200 100', '-200 200', '-100 -200', '-100 -100', '-100 0', '-100 100', '-100 200', '0 -200', '0 -100', '0 0', '0 100', '0 200', '100 -200', '100 -100', '100 0', '100 100', '100 200', '200 -200', '200 -100', '200 0', '200 100', '200 200'] postiro = []
for i in range(5):
for j in range(5):
postiro.append(f"{(i-2) * 100} {(j-2) * 100}")
print((i-2) * 100, (j-2) * 100)
#postiro = ['-200 -200', '-200 -100', '-200 0', '-200 100', '-200 200', '-100 -200', '-100 -100', '-100 0', '-100 100', '-100 200', '0 -200', '0 -100', '0 0', '0 100', '0 200', '100 -200', '100 -100', '100 0', '100 100', '100 200', '200 -200', '200 -100', '200 0', '200 100', '200 200']
tl.setup(650,650,None,None) tl.setup(650,650,None,None)
tl.title("Naval Battle 1943 Loading...") tl.title("Naval Battle 1943 Loading...")
tl.speed(0) tl.speed(0)
#funções #funções
def linhax(x,y): def linhax(x,y):
tl.up(); tl.goto(x,y) tl.up(); tl.goto(x,y)
tl.down(); tl.goto(x+600,y) tl.down(); tl.goto(x+600,y)
pass pass
def linhay(x,y): def linhay(x,y):
tl.up(); tl.goto(x,y) tl.up(); tl.goto(x,y)
tl.down(); tl.goto(x,y+600) tl.down(); tl.goto(x,y+600)
pass pass
#radar screen #radar screen
@ -33,18 +37,14 @@ linhay(300,-300)
linhax(-300,300) linhax(-300,300)
#linhas X #linhas X
linhax(-300,-200); tl.write("-200",False,align="right") for i in range(5):
linhax(-300,-100); tl.write("-100",False,align="right") linhax(-300, (i-2)*100)
linhax(-300,0); tl.write("0",False,align="right") tl.write(str((i-2) * 100), False, align="right")
linhax(-300,100); tl.write("100",False,align="right")
linhax(-300,200); tl.write("200",False,align="right")
#linhas Y #linhas Y
linhay(-200,-300); tl.write("-200",False,align="right") for i in range(5):
linhay(-100,-300); tl.write("-200",False,align="right") linhay((i-2)*100, -300)
linhay(0,-300); tl.write("-200",False,align="right") tl.write(str((i-2) * 100), False, align="right")
linhay(100,-300); tl.write("-200",False,align="right")
linhay(200,-300); tl.write("-200",False,align="right")
#Tabuleiro pronto #Tabuleiro pronto
tl.title("Naval Battle 1943") tl.title("Naval Battle 1943")
tl.hideturtle() tl.hideturtle()
@ -63,7 +63,7 @@ e2.up()
e2.color("red") e2.color("red")
e2.goto(random.choice(posx), random.choice(posy)) e2.goto(random.choice(posx), random.choice(posy))
if e1.pos() == e2.pos(): if e1.pos() == e2.pos():
e2.goto(random.choice(posx), random.choice(posy)) e2.goto(random.choice(posx), random.choice(posy))
e3 = tl.Turtle() e3 = tl.Turtle()
@ -71,44 +71,25 @@ e3.up()
e3.color("red") e3.color("red")
e3.goto(random.choice(posx), random.choice(posy)) e3.goto(random.choice(posx), random.choice(posy))
if e1.pos() == e3.pos(): if e1.pos() == e3.pos():
e3.goto(random.choice(posx), random.choice(posy)) e3.goto(random.choice(posx), random.choice(posy))
if e2.pos() == e3.pos(): if e2.pos() == e3.pos():
e3.goto(random.choice(posx), random.choice(posy)) e3.goto(random.choice(posx), random.choice(posy))
#partidas #partidas
win = False win = False
while win == False: while win == False:
tirox = tl.numinput("linha X do disparo","Em qual quadrante X devemos disparar a artilharia") tirox = tl.numinput("linha X do disparo","Em qual quadrante X devemos disparar a artilharia")
tiroy = tl.numinput("linha Y do disparo","Em qual quadrante Y devemos disparar a artilharia") tiroy = tl.numinput("linha Y do disparo","Em qual quadrante Y devemos disparar a artilharia")
if (tirox,tiroy) == e1.pos(): if (tirox,tiroy) == e1.pos():
boat.goto(tirox,tiroy) boat.goto(tirox,tiroy)
print("Acerto!") print("Acerto!")
boat.write("U-boat Afundado\n Capitão!",False,align="center") boat.write("U-boat Afundado\n Capitão!",False,align="center")
break break
else: else:
boat.goto(tirox,tiroy) boat.goto(tirox,tiroy)
print("errou!") print("errou!")
boat.write("Erramos o alvo\n Capitão!",False,align="center") boat.write("Erramos o alvo\n Capitão!",False,align="center")
continue continue
#Execução #Execução
tl.mainloop() tl.mainloop()