In the game I am making, I want the player's character to be able to collide with certain tiles. I've done the code for it, however the player has a very strange hitbox. Here is the character with it's hitbox highlighted. I want it so that it only goes around the player and not the sword. Is this possible? Would I be able to only select a certain part of the rect?
This is what I've written for the collision at the moment:
for tile in world.tiles:
if tile[2] == True:
#check collision in x-axis
if tile[1].colliderect(self.rect.x + dx, self.rect.y, self.width, self.height):
dx = 0
The tuple values go like this (image, image_rect, if_an_object)
Thanks for any help in advance