So I've been working on a game and the biggest problem so far is that we cant get the player to collide with any of the objects on the field. Instead they go right through the tree. Can anyone tell me why? Here is the code I tried using for collision detection:
for tree in treelist:
if self.player.rect.x == tree.rect.x:
self.player.rect.x == self.player.rect.x - 2
if self.player.rect.x == tree.rect.x + tree.rect.width:
self.player.rect.x == self.player.rect.x + 2
if self.player.rect.y == tree.rect.y:
self.player.rect.y == self.player.rect.y - 2
if self.player.rect.y == tree.rect.y + tree.rect.height:
self.player.rect.y == self.player.rect.y + 2
Is this sound in theory or am I going about it all wrong?