Calculating the angle between the line defined by two points

前端 未结 6 1171
我在风中等你
我在风中等你 2020-11-28 08:17

I\'m currently developing a simple 2D game for Android. I have a stationary object that\'s situated in the center of the screen and I\'m trying to get that object to rotate

6条回答
  •  Happy的楠姐
    2020-11-28 08:20

    with pygame:

    dy = p1.y - p2.y
    dX = p2.x - p1.x
    
    rads = atan2(dy,dx)
    degs = degrees(rads)
    if degs < 0 :
       degs +=90
    

    it work for me

提交回复
热议问题