【发布时间】:2015-08-19 17:52:07
【问题描述】:
我想画一个吃豆人,它可以使用 python pygame 打开和关闭嘴巴。我找不到合适的文档。
我尝试使用此代码来回绘制圆弧和圆,它可以正常工作,但生成的形状似乎没有正确填充黄色,就像我只绘制圆时一样。
def draw(self, screen, count):
if count >0 and count <= 50:
pygame.draw.circle(screen, (255,255,0), (int(self.pos.x)+16, int(self.pos.y)+16), 16)
else:
if self.direction == Vector2D(1, 0):
pygame.draw.arc(screen, (255, 255, 0), (int(self.pos.x), int(self.pos.y), 32, 32),
0.7853981634, 5.4977871438, 16)
elif self.direction == Vector2D(-1, 0):
pygame.draw.arc(screen, (255, 255, 0), (int(self.pos.x), int(self.pos.y), 32, 32),
-2.356194490, 2.356194490, 16)
elif self.direction == Vector2D(0, -1):
pygame.draw.arc(screen, (255, 255, 0), (int(self.pos.x), int(self.pos.y), 32, 32),
2.3561944902, 7.0685834706, 16)
elif self.direction == Vector2D(0, 1):
pygame.draw.arc(screen, (255, 255, 0), (int(self.pos.x), int(self.pos.y), 32, 32),
-0.7853981634, 3.926990817, 16)
【问题讨论】:
-
何不试试看?
-
我尝试使用此代码绘制弧线,但生成的形状看起来好像没有正确填充颜色。 pygame.draw.arc(screen, (255,255,0), (int(pacman.pos.x), int(pacman.pos.y),width,height), 0.7853981634, 5.4977871438, 16)
-
如果您已经尝试过并且无法正常工作,请显示您的代码
-
似乎弧是一条线,而不是一个曲面。
标签: python python-2.7 animation pygame game-development