From 2efaab2ac8d95e3a4e3e0b52dffd9630906780a7 Mon Sep 17 00:00:00 2001 From: Elith Date: Sun, 16 Mar 2025 18:44:44 +0100 Subject: [PATCH] Calcul les points selon la position --- points.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 points.py diff --git a/points.py b/points.py new file mode 100644 index 0000000..54aa5f5 --- /dev/null +++ b/points.py @@ -0,0 +1,15 @@ +import math + +def points(x, y): + """Détermine si un tir vaut 2 ou 3 points en fonction de sa position.""" + # Centre du demi-cercle : (0, 300) | Rayon : 150 pixels + if x <= 150 and math.sqrt(x**2 + (y - 300)**2) <= 150: + return 2 + if x >= 850 and math.sqrt((x - 1000)**2 + (y - 300)**2) <= 150: + return 2 + return 3 + +# Test de la fonction +if __name__ == "__main__": + print(points(50, 300)) # Doit retourner 2 + print(points(500, 300)) # Doit retourner 3