Change ugly code

This commit is contained in:
20241144010020 2024-12-03 10:14:25 -03:00
parent 6dd9557681
commit 393c1b23b4
1 changed files with 18 additions and 5 deletions

View File

@ -32,12 +32,16 @@ tl.speed(0)
#funções
def linhax(x: int, y: int) -> None:
tl.up(); tl.goto(x,y)
tl.down(); tl.goto(x+600,y)
tl.up()
tl.goto(x,y)
tl.down()
tl.goto(x+600,y)
def linhay(x: int, y: int) -> None:
tl.up(); tl.goto(x,y)
tl.down(); tl.goto(x,y+600)
tl.up()
tl.goto(x,y)
tl.down()
tl.goto(x,y+600)
#radar screen
@ -60,10 +64,14 @@ for i in range(5):
#Tabuleiro pronto
tl.title("Naval Battle 1943")
tl.hideturtle()
boat = tl.Turtle()
boat.shapesize(3, 3)
boat.up(); boat.goto(0,0); boat.left(90)
boat.up()
boat.goto(0,0)
boat.left(90)
#Enemies
AMOUNT_OF_ENEMIES = 3
@ -73,10 +81,12 @@ for i in range(AMOUNT_OF_ENEMIES):
enemy = tl.Turtle()
enemy.color("red")
enemy.up()
if not has_argument(args, "D"):
enemy.hideturtle()
else:
enemy.shapesize(3, 3)
pos = [random.choice(posy), random.choice(posy)]
enemy.goto((pos[0] - 2) * 100, (pos[1] - 2) * 100)
@ -100,9 +110,11 @@ while win == False:
hit_enemy: list[tl.Turtle, list[int, int]] = enemy
acerto = True
break
if acerto:
print("Acerto!")
boat.write("U-boat Afundado\n Capitão!",False,align="center")
hit_enemy[0].hideturtle()
enemies.remove(hit_enemy)
else:
@ -114,4 +126,5 @@ while win == False:
win = True
print("Você ganhou!!")
tl.exitonclick()