本文整理汇总了Python中Ball.Ball.speed[1]方法的典型用法代码示例。如果您正苦于以下问题:Python Ball.speed[1]方法的具体用法?Python Ball.speed[1]怎么用?Python Ball.speed[1]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ball.Ball
的用法示例。
在下文中一共展示了Ball.speed[1]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loopGame
# 需要导入模块: from Ball import Ball [as 别名]
# 或者: from Ball.Ball import speed[1] [as 别名]
def loopGame(self):
clock = pygame.time.Clock()
ball = Ball([100,100])
paddle = Paddle([width/2,395])
font = pygame.font.Font(None, 25)
sound_collision = pygame.mixer.Sound("music/tick.mp3")
vector = []
posRectx = 90
posRecty = 60
score = 0
for i in range(0, 50):
if(i%5==0):
posRecty = posRecty + 20
posRectx = 80
else:
posRectx = posRectx + 80
rectColid = RectColid([posRectx,posRecty])
vector.append(rectColid)
running_game = True
while running_game:
clock.tick(120)
textoScore = font.render("Score: %d" % score, True, white)
for event in pygame.event.get():
if event.type==QUIT:
running_game = False
keys = pygame.key.get_pressed()
if keys[K_a]:
paddle.imagerect.centerx -= 5
if keys[K_d]:
paddle.imagerect.centerx += 5
if paddle.imagerect.colliderect(ball.imagerect):
if ball.speed[1] > 0:
ball.speed[1] = -ball.speed[1]
for rect in vector:
if rect.imagerect.colliderect(ball.imagerect):
vector.remove(rect)
ball.speed[1] = -ball.speed[1]
sound_collision.play(1)
score += 1
ball.update()
paddle.update()
screen.fill(black)
screen.blit(ball.image, ball.imagerect)
screen.blit(paddle.image, paddle.imagerect)
#Coloca os objetos na tela
for rect in vector:
screen.blit(rect.image, rect.imagerect)
screen.blit(textoScore, [10, 10])
pygame.display.flip()