本文整理汇总了Python中snake.Snake.changeDirection方法的典型用法代码示例。如果您正苦于以下问题:Python Snake.changeDirection方法的具体用法?Python Snake.changeDirection怎么用?Python Snake.changeDirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类snake.Snake
的用法示例。
在下文中一共展示了Snake.changeDirection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: in
# 需要导入模块: from snake import Snake [as 别名]
# 或者: from snake.Snake import changeDirection [as 别名]
pygame.mixer.music.pause()
elif GAMESTATE == 'pausing':
GAMESTATE = 'playing'
pygame.mixer.music.unpause()
if GAMESTATE == 'playing' and not isLocked:
newDirection = ''
if event.key in (K_DOWN, K_s):
newDirection = 'down'
elif event.key in (K_UP, K_w):
newDirection = 'up'
elif event.key in (K_LEFT, K_a):
newDirection = 'left'
elif event.key in (K_RIGHT, K_d):
newDirection = 'right'
if snake.isValidDirection(newDirection):
snake.changeDirection(newDirection)
isLocked = True
if event.type == QUIT:
# pygame.quit()
sys.exit()
if GAMESTATE == 'playing':
result = checkCollision()
if result == 0:
snake.moveForward()
elif result == 1:
snake.moveForward(True)
score += 1
isFruitShowing = False
if speed < 15:
speed *= 1.1
if score in (30, 50, 65, 75) or\