本文整理汇总了Python中ball.Ball.decreaseSpeed方法的典型用法代码示例。如果您正苦于以下问题:Python Ball.decreaseSpeed方法的具体用法?Python Ball.decreaseSpeed怎么用?Python Ball.decreaseSpeed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ball.Ball
的用法示例。
在下文中一共展示了Ball.decreaseSpeed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from ball import Ball [as 别名]
# 或者: from ball.Ball import decreaseSpeed [as 别名]
class Game:
'''
Main game class
'''
def __init__ (self):
pygame.init()
pygame.key.set_repeat(10,10)
res = ConfigManager.get("resolution")
self.screen = pygame.display.set_mode(res, pygame.DOUBLEBUF)
self.ball = Ball()
self.space = Space(res)
def catchUserInput(self):
for e in pygame.event.get():
if e.type == pygame.QUIT:
pygame.quit()
exit()
elif e.type == pygame.KEYDOWN:
if e.key == pygame.K_ESCAPE:
pygame.quit()
exit()
elif e.key == pygame.K_DOWN:
self.ball.decreaseSpeed()
elif e.key == pygame.K_UP:
self.ball.increaseSpeed()
elif e.key == pygame.K_LEFT:
self.ball.moveLeft()
elif e.key == pygame.K_RIGHT:
self.ball.moveRight()
def updateGameState(self):
self.ball.updateState()
def updateDisplay(self):
self.screen.fill(BLACK)
self.screen.blit(self.space, self.space.rect)
self.screen.blit(self.ball.image, self.ball.rect)
if __debug__:
#print "Debug mode: Draw sprite's rects"
pygame.draw.rect(self.screen, WHITE, self.ball.rect, 1)
#print "Debug mode: Draw statistics"
font = pygame.font.Font(None, 24)
speedMsg = "Spaceship speed: " + str(self.ball.speed)
posMsg = "Spaceship position: " + str(self.ball.rect)
textS = font.render(speedMsg, 1, GREEN)
textP = font.render(posMsg, 1, GREEN)
self.screen.blit(textS, (10,10))
self.screen.blit(textP, (10,25))
pygame.display.flip()
pygame.time.wait(1000 / 60)
def run(self):
while True:
self.catchUserInput()
self.updateGameState()
self.updateDisplay()