ちょっと矩形を中心に回転しようとしています。矩形を回転しようとすると、同時に左に移動します。誰にどのようにこれを修正するためのアイデアがありますか?あなたは、pygameのの内部には回転長方形で動作しないことを認識してんですが、 -Python/Pygameの矩形回転
def rotatePoint(self, angle, point, origin):
sinT = sin(radians(angle))
cosT = cos(radians(angle))
return (origin[0] + (cosT * (point[0] - origin[0]) - sinT * (point[1] - origin[1])),
origin[1] + (sinT * (point[0] - origin[0]) + cosT * (point[1] - origin[1])))
def rotateRect(self, degrees):
center = (self.collideRect.centerx, self.collideRect.centery)
self.collideRect.topleft = self.rotatePoint(degrees, self.collideRect.topleft, center)
self.collideRect.topright = self.rotatePoint(degrees, self.collideRect.topright, center)
self.collideRect.bottomleft = self.rotatePoint(degrees, self.collideRect.bottomleft, center)
self.collideRect.bottomright = self.rotatePoint(degrees, self.collideRect.bottomright, center)
だから、私は長方形の中の衝突があるかどうかを確認したい場合は、私はのコピーを作成する必要がありますということであると言っているのか長方形を作成し、それを毎回コピーから回転させますか?申し訳ありませんが、私はこれを理解するのに苦労しています。 – mramazingguy
将来的にこの問題に遭遇する人のために、彼が言っていることは、Pygameのエンジンは回転した四角形を理解していないということです。通常の回転していない長方形以外のものでは衝突検出を行うことはできません。 – atomictom