示例#1
0
    def __init__(self):
        super().__init__()

    def run(self):
        global running
        while running:
            c = str(msvcrt.getch())
            if c == "b'q'":
                running = False


input_thread = InputThread()
input_thread.start()
count = 0
while running:
    # ai设定n帧移动一次
    if count > 0:
        death = ai.action(radblock, beans)
        count = 0
    count += 1

    # 将墙的坐标导入
    displayer.extend_points(wall.points1)

    # 绘制图像
    displayer.draw__graphics(ai.points, radblock.points2, beans.point3)
    # 清屏
    displayer.clear()
    # time.sleep(snake.sleep_time)
    time.sleep(1)
示例#2
0
                running = False
            elif c == "b'w'":
                snake.set_toward("UP")
            elif c == "b's'":
                snake.set_toward("DOWN")
            elif c == "b'a'":
                snake.set_toward("LEFT")
            elif c == "b'd'":
                snake.set_toward("RIGHT")


input_thread = InputThread()
input_thread.start()

while running:
    #蛇动
    death = snake.action(bug, wall.points)
    if death:
        print("小蛇蛇死了\n按q键退出\n")
        break

    #将墙的坐标导入
    displayer.extend_points(wall.points)
    displayer.extend_points(radblock.points)

    #绘制图像
    displayer.draw__graphics(snake.score, snake.points, bug.point)
    #清屏
    displayer.clear()
    #time.sleep(snake.sleep_time)
    time.sleep(1)