Pygame连接多个点

时间:2019-05-08 20:29:33

标签: python pygame

我正在用Pygame在Python上编写一个游戏,在该游戏中,玩家是一个矩形,后面是一条轨迹,该轨迹由显示器上的点列表组成。现在,当绘制路径时,边缘非常锋利而不是光滑。有一个更好的方法吗?谢谢!

现在,trail_locations是一个元组列表,其中每个元组是玩家行进的每个(x,y)位置,我正在画一条连接所有点的线。

这是我用来吸引用户的代码

    def draw_user(self, player: Vehicle):
    """
    draws player as a rectangle
    :param player: Vehicle object
    :return: None
    """
    pygame.draw.rect(self.gameDisplay, player.get_color(),
                     [player.get_x(), player.get_y(), player.get_width(),
                      player.get_height()])
    trail = player.get_trail()
    #trail_locations is a list of tuples, where each tuple is a (x,y) coordinate of where they have traveled
    trail_locations = trail.get_locations()
    for i in range(1, len(trail_locations)):
        pygame.draw.line(self.gameDisplay, player.get_color(),
                         list(trail_locations[i]),
                         list(trail_locations[i]), trail.get_width())

0 个答案:

没有答案