赞
踩
见缝插针小游戏,设置关卡,难度逐渐增大,效果图如下,需要的话去个人主页提取资源
部分代码如下:
def __init__(self, angle):
self.x = x0
self.y = y0 + length
self.center = (self.x, self.y)
self.radius = 12
self.angle = angle
ball_group.append(self)
def draw(self, surface):
pygame.draw.line(surface, WHITE, shaft, self.center, 2)
pygame.draw.circle(surface, WHITE, self.center, 12)
def move(self, speed):
"""
围绕转轴做圆周运动
:param speed: 转动的角速度
:return:
"""
if self.angle < 2 * math.pi:
self.angle += speed
else:
self.angle = self.angle - 2 * math.pi
self.x = x0 - length * math.sin(self.angle)
self.y = y0 + length * math.cos(self.angle)
self.center = (self.x, self.y)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。