I am currently working on a simple flappy bird-ish game on Python. For some reason, the collision code isn't working when the pipe and bird touch.
def collision():
global distanceDown, distanceUp
distanceUp = math.sqrt(math.pow(pipeUpX - birdX, 2) + math.pow(pipeUpY - birdY, 2)) # distance formula
distanceDown = math.sqrt(math.pow(pipeDownX - birdX, 2) + math.pow(pipeDownX - birdY, 2))
if distanceUp <= 20 or distanceDown <= 20:
return True
else:
return False
I've called the function in the main game loop and asked python to end the game if true, but the bird just passes through the pipe.FYI, I haven't used OOP and classes.Here are the values..
pipeWidth = 50
pipeHeight = 130
pipeUpX = 800
pipeUpY = 0
pipeDownY = screenY - pipeHeight
pipeDownX = 900
pipeX_change = 1
Also, I'm quite new to python and programming as a whole, so please answer in easy to understand code. Thank You :)