Jogo Base do Batalha Naval

This commit is contained in:
Kaio Henrique 2024-11-19 21:06:08 -03:00
parent a289dd7bfc
commit 2f4ed66753
1 changed files with 113 additions and 0 deletions

View File

@ -0,0 +1,113 @@
#setup
import turtle as tl
import random
import time as tm
posx = [-300, -250, -200, -150, -100, -50, 50, 100, 150, 200, 250, 300]
posy = [-300, -250, -200, -150, -100, -50, 50, 100, 150, 200, 250, 300]
tl.setup(600,600,None,None)
tl.title("U-Boat Radar 1943")
tl.speed(0)
#funções
def linhax(x,y):
tl.up(); tl.goto(x,y)
tl.down(); tl.goto(x+600,y)
pass
def linhay(x,y):
tl.up(); tl.goto(x,y)
tl.down(); tl.goto(x,y+600)
pass
#radar screen
tl.bgcolor("lime green")
#moldura
linhax(-300,-300)
linhay(-300,-300)
linhay(300,-300)
linhax(-300,300)
#linhas X
linhax(-300,-250)
linhax(-300,-200)
linhax(-300,-150)
linhax(-300,-100)
linhax(-300,-50)
linhax(-300,0)
linhax(-300,50)
linhax(-300,100)
linhax(-300,150)
linhax(-300,200)
linhax(-300,250)
#linhas Y
linhay(-250,-300)
linhay(-200,-300)
linhay(-150,-300)
linhay(-100,-300)
linhay(-50,-300)
linhay(0,-300)
linhay(50,-300)
linhay(100,-300)
linhay(150,-300)
linhay(200,-300)
linhay(250,-300)
#Tabuleiro pronto
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))
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.goto(random.choice(posx), random.choice(posy))
#partidas
win = False
while win == False:
print("Ola Comandante, Onde devemos bombardear:")
tiro1 = int(input("Onde miraremos a primeira salva:"))
tiro2 = int(input("Onde miraremos a segunda salva"))
tiro3 = int(input("Onde miraremos a terceira salva"))
#Execução
tl.mainloop()
tl.exitonclick()