My problem is that my character is constantly jumping. How can I prevent this?
Video of my problem: https://www.youtube.com/watch?v=QwmAdzEJH-0
Here is my code(I think this part is wrong):
hitbox = pygame.draw.rect(win, (255, 255, 255), self.hitbox, 1)
first_rect = pygame.draw.rect(win, (0, 0, 0), [385, 465, 117, 75])
second_rect = pygame.draw.rect(win, (0,0,0), [494, 390, 120, 80])
ucuncu_rect = pygame.draw.rect(win, (0,0,0), [596,308,117,84])
dorduncu_rect = pygame.draw.rect(win, (0, 0, 0), [701,240,270,70])
if hitbox.colliderect(first_rect):
if abs(first_rect.left - hitbox.right) < 10:
self.x -= 10
elif abs(first_rect.top - hitbox.bottom) < 10:
self.y = 314
if hitbox.colliderect(second_rect):
if abs(second_rect.left - hitbox.right) < 10:
self.x -= 5
elif abs(second_rect.top - hitbox.bottom) < 60:
self.y -= 70
if hitbox.colliderect(ucuncu_rect):
if abs(ucuncu_rect.left - hitbox.right) < 10:
self.x -= 5
elif abs(ucuncu_rect.top - hitbox.bottom) < 55:
self.y -= 41
if hitbox.colliderect(dorduncu_rect):
if abs(dorduncu_rect.left - hitbox.right) < 10:
self.x -= 5
elif abs(dorduncu_rect.top - hitbox.bottom) < 55:
self.y -= 35
elif (self.y < 450) and (self.isJump == False):
self.y += 10