[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Sprite Collision



Now that my AI is chasing the Ninja around, I'd like to make it so that when they bump into a block, they "slide" around it. I figured I'd do this by having it find out where the block is in relation to the monster, and then stop moving in the direction that was causing it to bump into the block. But I don't want to say "for block in block_group" because that eats up too much CPU, so my question is, how can I figure out where the block is without using that? Is there an easier way to solve the problem?
I tried just using ifs to do it (It looked something like: If self.x_dir == 1 and self.y_dir == 1, self.x_dir = 1 and self.y_dir = 0) but then the monsters just floated over the blocks.
Thanks!