本文整理汇总了Python中cube.Cube.scramble方法的典型用法代码示例。如果您正苦于以下问题:Python Cube.scramble方法的具体用法?Python Cube.scramble怎么用?Python Cube.scramble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cube.Cube
的用法示例。
在下文中一共展示了Cube.scramble方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main_loop
# 需要导入模块: from cube import Cube [as 别名]
# 或者: from cube.Cube import scramble [as 别名]
def main_loop(screen):
""" Run the main game loop. """
cube = Cube()
the_renderer = renderer.Renderer(screen)
projection = 'default'
show_help = True
while True:
screen.erase()
screen.box()
the_renderer.render(cube, projection)
if show_help:
the_renderer.add_help_strings()
if cube.solved:
the_renderer.add_solved_string()
screen.refresh()
key = screen.getkey()
logging.debug('Key press {}'.format(key))
if key == 'KEY_F(1)':
show_help = not show_help
elif key == '1':
projection = 'default' # Front view
elif key == '3':
projection = 'multi' # Orthographic projection view
elif key == 'x':
cube.rotate(0) # Rotate about x-axis
elif key == 'X':
cube.rotate(0, sign=-1) # Rotate about x-axis in CCW direction
elif key == 'y':
cube.rotate(1)
elif key == 'Y':
cube.rotate(1, sign=-1)
elif key == 'z':
cube.rotate(2)
elif key == 'Z':
cube.rotate(2, sign=-1)
elif key == 'j':
cube.twist('top')
elif key == 'J':
cube.twist('top', sign=-1)
elif key == 'i':
cube.twist('middle') # horizontal
elif key == 'I':
cube.twist('middle', sign=-1)
elif key == 'k':
cube.twist('bottom')
elif key == 'K':
cube.twist('bottom', sign=-1)
elif key == 'h':
cube.twist('left')
elif key == 'H':
cube.twist('left', sign=-1)
elif key == 'm':
cube.twist('center') # vertical
elif key == 'M':
cube.twist('center', sign=-1)
elif key == 'l':
cube.twist('right')
elif key == 'L':
cube.twist('right', sign=-1)
elif key == 's':
cube.scramble()
elif key == 'S':
cube.solve()
elif key == 'q':
break # Exit the while loop
screen.erase() # Avoid flashing reset colours
screen.refresh()