Box collision detection and bouncing

后端 未结 4 1659
一生所求
一生所求 2021-01-27 14:07

I\'m making pong, and am finding it really difficult to write an algorithm that bounces the ball off the four walls properly (I will deal with scoring later on, because only par

4条回答
  •  北恋
    北恋 (楼主)
    2021-01-27 14:12

    Thanks @jbx, I knew there was a simpler way :) However, that doesn't seem to work for the east and west walls and the paddles (if they're on those walls). This seems to work for me on the east and west walls though:

    (180 - (angle + 90)) - 90.
    

    which simplifies to just (180-angle). Hope that helps.

提交回复
热议问题