How do I create collision detections for my bouncing balls?

后端 未结 7 1253
星月不相逢
星月不相逢 2021-02-04 18:13

I have coded an animation (in python) for three beach balls to bounce around a screen. I now wish to have them all collide and be able to bounce off each other. I would really a

7条回答
  •  爱一瞬间的悲伤
    2021-02-04 18:35

    I think there is somehthing simpler that you guys are missing espeically considering he's using pygame.

    Calling the get_rect function can set probably boundraies for the images and Rect that is created, is used for calculating the position of the image and if there are more than one object in the animation, it can be used for detecting collisions.

    colliderect & rect can be used, problem is i have no idea how you would implement it especially for an unkown number of balls.

    Keeping in mind it's python.

提交回复
热议问题