forked from 20241144010013/20241144010013
Naval Battle 1.1
This commit is contained in:
parent
92a6efc621
commit
93eda0f85f
|
@ -1,3 +1,4 @@
|
|||
#esse jogo ainda está sob teste... e não deve ser considerado completo
|
||||
#setup
|
||||
import turtle as tl
|
||||
import random
|
||||
|
@ -19,7 +20,7 @@ tiro_pos = {
|
|||
"B2": (100,100),
|
||||
"B3": (100,0),
|
||||
"B4": (100,-100),
|
||||
"B5": (100,-100),
|
||||
"B5": (100,-200),
|
||||
"C1": (0,200),
|
||||
"C2": (0,100),
|
||||
"C3": (0,0),
|
||||
|
@ -37,23 +38,21 @@ tiro_pos = {
|
|||
"E5": (-200,-200),
|
||||
}
|
||||
|
||||
|
||||
|
||||
#funções
|
||||
def linhax(x,y):
|
||||
tl.up(); tl.goto(x,y)
|
||||
tl.down(); tl.goto(x+600,y)
|
||||
pass
|
||||
#pass
|
||||
|
||||
def linhay(x,y):
|
||||
tl.up(); tl.goto(x,y)
|
||||
tl.down(); tl.goto(x,y+600)
|
||||
pass
|
||||
|
||||
#pass
|
||||
|
||||
#radar screen
|
||||
tl.bgcolor("lime green")
|
||||
#moldura
|
||||
tl.tracer(0)
|
||||
linhax(-300,-300)
|
||||
linhay(-300,-300)
|
||||
linhay(300,-300)
|
||||
|
@ -73,58 +72,105 @@ linhay(0,-300); tl.write("C",False,align="right")
|
|||
linhay(100,-300); tl.write("B",False,align="right")
|
||||
linhay(200,-300); tl.write("A",False,align="right")
|
||||
#Tabuleiro pronto
|
||||
tl.update()
|
||||
tl.tracer(1)
|
||||
tl.title("Naval Battle 1943")
|
||||
tl.hideturtle()
|
||||
boat = tl.Turtle()
|
||||
boat.up(); boat.goto(0,0); boat.left(90)
|
||||
|
||||
#Enemies
|
||||
e1 = tl.Turtle()
|
||||
e1.up()
|
||||
e1.color("red")
|
||||
e1.goto(random.choice(posx), random.choice(posy))
|
||||
bullet = tl.Turtle()
|
||||
bullet.color("Yellow")
|
||||
bullet.hideturtle()
|
||||
bullet.up()
|
||||
|
||||
#gamemode SinglePlayer
|
||||
gmode = tl.textinput("Modo de Jogo","Qual Modo Deseja jogar?\ndigite multi para jogar com um amigo do lado\ne single para jogar sozinho")
|
||||
if gmode == "single":
|
||||
win = False
|
||||
print("Modo Solitario Selecionado! escolha onde ficaram seus navios")
|
||||
#Player 1
|
||||
p1 = tl.Turtle()
|
||||
p1.up()
|
||||
spawnp1 = 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? "))
|
||||
p2.goto(tiro_pos[spawnp2])
|
||||
|
||||
p3 = tl.Turtle()
|
||||
p3.up()
|
||||
spawnp3 = str(input("Senhor, Onde Nosso Destroyer Deve Ficar? "))
|
||||
p3.goto(tiro_pos[spawnp3])
|
||||
#pass
|
||||
|
||||
#inimigos
|
||||
e1 = tl.Turtle()
|
||||
e1.up()
|
||||
e1.color("red")
|
||||
e1.goto(random.choice(posx), random.choice(posy))
|
||||
|
||||
|
||||
e2 = tl.Turtle()
|
||||
e2.up()
|
||||
e2.color("red")
|
||||
e2.goto(random.choice(posx), random.choice(posy))
|
||||
if e1.pos() == e2.pos():
|
||||
e2 = tl.Turtle()
|
||||
e2.up()
|
||||
e2.color("red")
|
||||
e2.goto(random.choice(posx), random.choice(posy))
|
||||
if e1.pos() == e2.pos():
|
||||
e2.goto(random.choice(posx), random.choice(posy))
|
||||
|
||||
|
||||
e3 = tl.Turtle()
|
||||
e3.up()
|
||||
e3.color("red")
|
||||
e3.goto(random.choice(posx), random.choice(posy))
|
||||
if e1.pos() == e3.pos():
|
||||
e3.goto(random.choice(posx), random.choice(posy))
|
||||
if e2.pos() == e3.pos():
|
||||
e3 = tl.Turtle()
|
||||
e3.up()
|
||||
e3.color("red")
|
||||
e3.goto(random.choice(posx), random.choice(posy))
|
||||
if e1.pos() == e3.pos():
|
||||
e3.goto(random.choice(posx), random.choice(posy))
|
||||
if e2.pos() == e3.pos():
|
||||
e3.goto(random.choice(posx), random.choice(posy))
|
||||
#pass
|
||||
|
||||
while win == False:
|
||||
e1_sunk = False
|
||||
e2_sunk = False
|
||||
e3_sunk = False
|
||||
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()
|
||||
bullet.goto(tiro_pos[tiro])
|
||||
print("Acerto!")
|
||||
bullet.write("U-boat Afundado\n Capitão!",False,align="center")
|
||||
bullet.hideturtle()
|
||||
e1_sunk = True
|
||||
#acerto Crusador
|
||||
elif (tiro_pos[tiro]) == e2.pos():
|
||||
bullet.showturtle()
|
||||
bullet.goto(tiro_pos[tiro])
|
||||
print("Acerto!")
|
||||
bullet.write("Crusador Afundado\n Capitão!",False,align="center")
|
||||
bullet.hideturtle()
|
||||
e2_sunk = True
|
||||
#acerto Destroyer
|
||||
elif(tiro_pos[tiro]) == e3.pos():
|
||||
bullet.showturtle()
|
||||
bullet.goto(tiro_pos[tiro])
|
||||
print("Acerto!")
|
||||
bullet.write("Destroyer Afundado\n Capitão!",False,align="center")
|
||||
bullet.hideturtle()
|
||||
e3_sunk = True
|
||||
#erro
|
||||
elif (tiro_pos[tiro]) != e1.pos() or (tiro_pos[tiro]) != e2.pos() or (tiro_pos[tiro]) != e3.pos():
|
||||
bullet.showturtle()
|
||||
bullet.goto(tiro_pos[tiro])
|
||||
print("errou!")
|
||||
bullet.write("Erramos o alvo\n Capitão!",False,align="center")
|
||||
bullet.hideturtle()
|
||||
continue
|
||||
|
||||
#partidas
|
||||
win = False
|
||||
while win == False:
|
||||
tiro = tl.textinput("linha X do disparo","Em qual quadrante X devemos disparar a artilharia")
|
||||
if (tiro_pos[tiro]) == e1.pos() or (tiro_pos[tiro]) == e2.pos() or (tiro_pos[tiro]) == e3.pos():
|
||||
boat.goto(tiro_pos[tiro])
|
||||
print("Acerto!")
|
||||
boat.write("U-boat Afundado\n Capitão!",False,align="center")
|
||||
break
|
||||
elif e1_sunk == True and (e2_sunk == True) and (e3_sunk == True):
|
||||
break
|
||||
else:
|
||||
boat.goto(tiro_pos[tiro])
|
||||
print("errou!")
|
||||
boat.write("Erramos o alvo\n Capitão!",False,align="center")
|
||||
continue
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
print("Voçe ganhou!")
|
||||
|
||||
|
||||
|
||||
|
@ -133,9 +179,89 @@ while win == False:
|
|||
|
||||
|
||||
|
||||
#Multiplayer
|
||||
elif gmode == "multi":
|
||||
win = False
|
||||
print("Modo Multiplayer Selecionado! Fique ao lado de seu amigo\nnão olhe os navios dele e vice-versa")
|
||||
#Player 1
|
||||
p1 = tl.Turtle()
|
||||
p1.up()
|
||||
spawnp1 = 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? "))
|
||||
p2.goto(tiro_pos[spawnp2])
|
||||
|
||||
p3 = tl.Turtle()
|
||||
p3.up()
|
||||
spawnp3 = str(input("Senhor, Onde Nosso Destroyer Deve Ficar? "))
|
||||
p3.goto(tiro_pos[spawnp3])
|
||||
#pass
|
||||
|
||||
#player 2
|
||||
p1_2 = tl.Turtle()
|
||||
p1_2.up()
|
||||
spawnp1_2 = str(input("Senhor, Onde Nosso Submarino Deve Ficar? "))
|
||||
p1_2.goto(tiro_pos[spawnp1_2])
|
||||
|
||||
p2_2 = tl.Turtle()
|
||||
p2_2.up()
|
||||
spawnp2_2 = str(input("Senhor, Onde Nosso Crusador Deve Ficar? "))
|
||||
p2_2.goto(tiro_pos[spawnp2_2])
|
||||
|
||||
p3_2 = tl.Turtle()
|
||||
p3_2.up()
|
||||
spawnp3_2 = str(input("Senhor, Onde Nosso Destroyer Deve Ficar? "))
|
||||
p3_2.goto(tiro_pos[spawnp3_2])
|
||||
#pass
|
||||
|
||||
while win == False:
|
||||
tiro = tl.textinput("linha X do disparo","Em qual quadrante X devemos disparar a artilharia")
|
||||
if (tiro_pos[tiro]) == p1.pos() or (tiro_pos[tiro]) == p1_2.pos():
|
||||
bullet.showturtle()
|
||||
bullet.goto(tiro_pos[tiro])
|
||||
print("Acerto!")
|
||||
bullet.write("U-boat Afundado\n Capitão!",False,align="center")
|
||||
bullet.hideturtle()
|
||||
break
|
||||
elif (tiro_pos[tiro]) == p2.pos() or (tiro_pos[tiro]) == p2_2.pos():
|
||||
bullet.showturtle()
|
||||
bullet.goto(tiro_pos[tiro])
|
||||
print("Acerto!")
|
||||
bullet.write("Crusador Afundado\n Capitão!",False,align="center")
|
||||
bullet.hideturtle()
|
||||
break
|
||||
elif(tiro_pos[tiro]) == p3.pos() or (tiro_pos[tiro]) == p3_2.pos():
|
||||
bullet.showturtle()
|
||||
bullet.goto(tiro_pos[tiro])
|
||||
print("Acerto!")
|
||||
bullet.write("Destroyer Afundado\n Capitão!",False,align="center")
|
||||
bullet.hideturtle()
|
||||
break
|
||||
else:
|
||||
bullet.showturtle()
|
||||
bullet.goto(tiro_pos[tiro])
|
||||
print("errou!")
|
||||
bullet.write("Erramos o alvo\n Capitão!",False,align="center")
|
||||
bullet.hideturtle()
|
||||
continue
|
||||
#partidas
|
||||
|
||||
#Execução
|
||||
tl.mainloop()
|
||||
tl.exitonclick()
|
||||
tl.exitonclick()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue