I'm making a sidescrolling game in Pygame, and if the fox sprite collides with the tree, it is supposed to print "COLLIDE". But it doesn't work. How can I fix this to detect collision between the fox and the tree? Here's the code:
if foxsprite1 > xtree and foxsprite1 < xtree + treewidth or foxsprite1 + treewidth > xtree and foxsprite1 + treewidth < xtree + treewidth: print ("COLLIDE")
xtree is the x coordinate of the tree, treewidth is the width of the tree, and foxsprite1 is the fox.