好的,所以我正在使用 pygame.draw 在名为 Entity 的类中制作一个简笔画:
class Entity: #Used with default arguments blited on a 600 by 600 pixel screen
def __init__(self, pos=[300, 300]):
self.pos = pos
self.legR = [10, 25]
self.legL = [-10, -25]
self.armR = [0, 0]
self.armL = [0, 0]
self.body = [30, 5]
self.head = [0, 0, 5]
self.size = [60, 110]
self.color = [0, 0, 0]
self.image = pygame.surface.Surface(self.size)
self.image.fill([255, 255, 255])
def render(self, screen, frame):
self.image = pygame.surface.Surface(self.size)
self.image.fill([255, 255, 255])
pygame.draw.line(self.image, self.color, [self.size[0]/2, self.size[1]/2],
[self.size[0]/2+self.legR[0], self.size[0]/2+self.legR[1]], 5)
pygame.draw.line(self.image, self.color, [self.size[0]/2, self.size[1]/2],
[self.size[0]/2+self.legL[0], self.size[0]/2+self.legL[1]], 5)
pygame.draw.line(self.image, self.color, [self.size[0]/2, self.size[1]/2],
[self.size[0]/2+self.body[0], self.size[0]/2+self.body[1]], self.body[1])
pygame.draw.circle(self.image, self.color,
[self.size[0]/2+self.body[0]+self.head[0], self.size[1]/2+self.body[1]+self.head[1]],
self.head[2])
#pygame.draw.line(self.image, self.color, [self.size/2
screen.blit(self.image, self.pos)
所以我运行它,它给了我这个奇怪的混乱图像,带有一堆随机方向的线条。在我看来,我不太了解这个功能。我可以举一个带有可配置关节的可渲染简笔画的例子吗?如果没有,有人可以请至少告诉我我的致命错误吗?谢谢!