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