本文整理汇总了Python中snake.Snake.moveForward方法的典型用法代码示例。如果您正苦于以下问题:Python Snake.moveForward方法的具体用法?Python Snake.moveForward怎么用?Python Snake.moveForward使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类snake.Snake
的用法示例。
在下文中一共展示了Snake.moveForward方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: in
# 需要导入模块: from snake import Snake [as 别名]
# 或者: from snake.Snake import moveForward [as 别名]
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\
(score > 75 and (score - 80) % 5 == 0):
soundJiayou.play()
elif result == -1:
GAMESTATE = 'over'
soundFail.play()
drawFinal()
redraw()
elif GAMESTATE == 'over':