Fix hitbox

This commit is contained in:
WildTrack
2019-05-09 12:45:07 +02:00
parent 112183d0d2
commit 06b4a8680b

View File

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