小编CFJ*_*CFJ的帖子

在 PyGame 中绘制跟随线条方向的箭头

在 Pygame 中,如何计算箭头的三个点的坐标,给定箭头的起点和终点,使箭头指向与线相同的方向?

def __draw_arrow(self, screen, colour, start, end):     
    start = self.__coordinate_lookup[start]
    end = self.__coordinate_lookup[end]
    dX = start[0] - end[0]
    dY = -(start[1] - end[1])
    print m.degrees(m.atan(dX/dY)) + 360 
    pygame.draw.line(screen,colour,start,end,2)
Run Code Online (Sandbox Code Playgroud)

我试过尝试使用角度和线条的梯度,Y 坐标向下而不是向上增加的事实让我失望,我真的很感激朝正确的方向轻推。

python geometry pygame algebra python-2.7

5
推荐指数
1
解决办法
2209
查看次数

标签 统计

algebra ×1

geometry ×1

pygame ×1

python ×1

python-2.7 ×1