darts.py functions removed

This commit is contained in:
TiagoRG 2023-01-30 18:52:46 +00:00
parent 27e35ad2f1
commit d8a641fad0
Signed by untrusted user who does not match committer: TiagoRG
GPG Key ID: DFCD48E3F420DB42
1 changed files with 22 additions and 35 deletions

View File

@ -1,11 +1,8 @@
import math import math
POINTS = (6, 13, 4, 18, 1, 20, 5, 12, 9, 14, 11, 8, 16, 7, 19, 3, 17, 2, 15, 10)
def main(): print("Introduza as coordenadas (x, y) do dardo.\nRepresenta as posicoes horizontal e vertical respetivamente.\nAmbas em milimetros.")
print("""Introduza as coordenadas (x, y) do dardo.
Representa as posicoes horizontal e vertical respetivamente.
Ambas em milimetros.
""")
x = int(input('X: ')) x = int(input('X: '))
y = int(input('Y: ')) y = int(input('Y: '))
@ -14,16 +11,19 @@ Ambas em milimetros.
if mod > 170: if mod > 170:
print('Fora do alvo.') print('Fora do alvo.')
return exit(1)
if mod < 12.7: if mod < 12.7:
print('Pontuacao: 50 pontos.') print('Pontuacao: 50 pontos.')
return exit(1)
elif mod < 32: elif mod < 32:
print('Pontuacao: 25 pontos.') print('Pontuacao: 25 pontos.')
return exit(1)
angleRad = math.atan2(y, x)
angleDeg = math.degrees(angleRad) - 9
score = POINTS[int(angleDeg / 20)]
score = BasePoint(x, y)
if 99 < mod < 107: if 99 < mod < 107:
score *= 3 score *= 3
if mod > 162: if mod > 162:
@ -31,16 +31,3 @@ Ambas em milimetros.
print(f'Pontuacao: {score} pontos.') print(f'Pontuacao: {score} pontos.')
exit(1) exit(1)
def BasePoint(x, y):
angleRad = math.atan2(y, x)
angleDeg = math.degrees(angleRad) - 9
POINTS = (6, 13, 4, 18, 1, 20, 5, 12, 9, 14, 11, 8, 16, 7, 19, 3, 17, 2, 15, 10)
return POINTS[int(angleDeg / 20)]
if __name__ == '__main__':
main()