How do I get collision to detect properly in pygame [closed]

15 hours ago 3
ARTICLE AD BOX

Here is what the collision looks like fast than slow
https://imgur.com/a/JNVEdUV

player = Block(500, 300, 20, 20, "blue") surfaceList = [Block(500, 100, 60, 10, "orange"), Block(500, 110, 60, 30, "red"), Block(500, 140, 60, 10, "orange")] --- MAIN LOOP --- # COLLISION collision_target = None # Track which surface the player is colliding with target = player.rect.collidelist(surfaceList) if target != -1: collision_target = target if collision_target == 1 and key[pygame.K_SPACE] == target: player.color = "green" else: player.color = "blue" # Draw for i in surfaceList: i.drawSurface(screen)

I am trying to get the block to detect when I hit the spacebar

What i've done so far is change the FPS, added a target to detect precise collision but still does not detect properly, especially when the FPS is increased to what I want.

Without the target I know it works but still not precise

How can I fix this

Read Entire Article