I am programming a ray tracer in python, and I have gotten as far as making a character that can move across a 2d plane and change direction of movement when needed. The problem is this: I want to be able to use an image with transparency as the maze that the player travels through, and use transparent parts as parts that aren't walls, where as every thing else is a wall. The way I am using collision detection is by using the "pygame.sprite.spritecollide"pygame.sprite.spritecollide method, which takes in a Sprite, and a Sprite Group. So I first add the map sprite object to the group, and then in the main while loop, it checks for collision. Here is a small snippet of what that might look like:
map = Map("map1.png") # "Map" class is regular sprite class but with "image" and "rect"
group = pygame.sprite.Group()
group.add(map)
# inbetween stuff would be here
# while loop \/
running = True
while running:
# event handling stuff would be here
if pygame.sprite.spritecollide(player, group, False):
print True
# screen drawing routines would be here
As I mentioned, the image has transparency. But never the lessnevertheless, the image rect sticks to the non transparency position that it was, so iI have to move the player off screen to get the console to stop saying "True".
So what I ask, is there a way that I can check for sprite collision but with transparency?