nickqqqq1
nickqqqq1

Reputation: 107

How to check collision between the mouse and a sprite group

I'm trying detect collision between the mouse and a sprite group. I have searched around for awhile but couldn't find anything about it. So if you know how to do this could you please explain how such a thing is done? If so I would greatly appreciate it. Also I'm not exactly sure which parts of code I would need to show you but if you need any please tell me what part of it you would need and I will post it.

Upvotes: 0

Views: 792

Answers (1)

Bartlomiej Lewandowski
Bartlomiej Lewandowski

Reputation: 11170

If you are using pygame, the easiest way is to create a Sprite that will not have a image, and the position will change with the mouse. To access the mouse coordinates use :

pygame.mouse.get_pos(): return (x, y)

then you can use your existing collision detection with this new Sprite.

Upvotes: 1

Related Questions