Fix hitbox
This commit is contained in:
@@ -54,6 +54,7 @@ def loop(deltatime: float, difficulty: float, end):
|
|||||||
deplacementtrait(difficulty)
|
deplacementtrait(difficulty)
|
||||||
|
|
||||||
_, _, x2, _ = canvas.coords(balle)
|
_, _, x2, _ = canvas.coords(balle)
|
||||||
|
|
||||||
if x2 >= 396:
|
if x2 >= 396:
|
||||||
end()
|
end()
|
||||||
return
|
return
|
||||||
@@ -68,18 +69,24 @@ def collision():
|
|||||||
xt1, yt1 = canvas.coords(trait)
|
xt1, yt1 = canvas.coords(trait)
|
||||||
xt1, yt1, xt2, yt2 = xt1 - 5, yt1 - 45, xt1 + 5, yt1 + 45
|
xt1, yt1, xt2, yt2 = xt1 - 5, yt1 - 45, xt1 + 5, yt1 + 45
|
||||||
x1, y1, x2, y2 = canvas.coords(balle)
|
x1, y1, x2, y2 = canvas.coords(balle)
|
||||||
|
|
||||||
if x1 <= 5:
|
if x1 <= 5:
|
||||||
cos = -cos
|
cos = -cos
|
||||||
if y1 <= 5 or y2 >= 295:
|
if y1 <= 5 or y2 >= 295:
|
||||||
sin = -sin
|
sin = -sin
|
||||||
if x2 + 5 >= xt1 and x1 - 5 <= xt2 and y1 - 5 <= yt2 and y2 + 5 >= yt1:
|
if x2 + 5 >= xt1 and x1 - 5 <= xt2 and y1 - 5 <= yt2 and y2 + 5 >= yt1:
|
||||||
|
if x1 + B_RADIUS >= xt1 + 5:
|
||||||
|
sin = -sin
|
||||||
|
else:
|
||||||
cos = -abs(cos)
|
cos = -abs(cos)
|
||||||
|
|
||||||
canvas.itemconfigure(balle, outline = ACCENT_COLOR, fill = ACCENT_COLOR)
|
canvas.itemconfigure(balle, outline = ACCENT_COLOR, fill = ACCENT_COLOR)
|
||||||
canvas.after(200, lambda: canvas.itemconfigure(balle, outline=SECONDARY_COLOR, fill=SECONDARY_COLOR))
|
canvas.after(200, lambda: canvas.itemconfigure(balle, outline=SECONDARY_COLOR, fill=SECONDARY_COLOR))
|
||||||
|
|
||||||
def deplacementtrait(difficulty: float):
|
def deplacementtrait(difficulty: float):
|
||||||
_, y1 = canvas.coords(trait)
|
_, y1 = canvas.coords(trait)
|
||||||
y1, y2 = y1 - 45, y1 + 45
|
y1, y2 = y1 - 45, y1 + 45
|
||||||
|
|
||||||
if haut and y1 >= 10:
|
if haut and y1 >= 10:
|
||||||
canvas.move(trait, 0, -PAST_Y * difficulty)
|
canvas.move(trait, 0, -PAST_Y * difficulty)
|
||||||
if bas and y2 <= 290:
|
if bas and y2 <= 290:
|
||||||
|
|||||||
Reference in New Issue
Block a user