Beispiel #1
0
def run():
    oper = input('请确保手机打开了 ADB 并连接了电脑,然后打开跳一跳并【开始游戏】后再用本程序,确定开始?y/n>>:')
    if oper != 'y':
        exit('退出')
    # 初始化,获取配置
    config = init()
    # 检测截图方式
    check_screenshot()
    print('通过第%s种方式获取截图' % SCREENSHOT_WAY)
    while True:
        # 获取截图

        get_screenshot()
        # 获取棋子,棋盘位置
        img = Image.open('autojump.png')
        piece_x, piece_y, board_x, board_y = find_piece_and_board(img, config)
        ntime = time.time()
        print(piece_x, piece_y, board_x, board_y, '------->')
        distance = math.sqrt((board_x - piece_x)**2 +
                             ((board_x - piece_x) / 1.7339)**2)
        # distance = math.sqrt((board_x - piece_x) ** 2 + (board_y - piece_y) ** 2)
        # 生成一个随机按压点,防止被ban
        if DEBUG:
            debug.save_debug_screenshot(ntime, img, piece_x, piece_y, board_x,
                                        board_y)
            debug.backup_screenshot(ntime)
        press_point = (random.randint(*config['swipe']['x']),
                       random.randint(*config['swipe']['y']))
        jump(distance, press_point, config['press_ratio'])

        time.sleep(random.randrange(1, 2))
Beispiel #2
0
def run():
    """主要函数,完成程序的主要任务"""
    open_game = input('请确保手机打开了 ADB 并连接了电脑,然后打开跳一跳并【开始游戏】后再用本程序,确定开始?y/n>>:')
    # if (open_game != 'y')or(open_game != 'Y'):
    #    exit('退出!')
    # 初始化:
    config = init()
    #检查截图方式:
    check_screenshot()
    print('通过第%s种方式获取截图' % SCREENSHOT_WAY)
    while True:
        #截图autojump.png
        get_screenShot()
        #读取截取的图片
        img = Image.open('autojump.png')
        piece_x, piece_y, board_x, board_y = find_piece_and_board(img, config)
        #计算棋子棋盘的距离
        ntime = time.time()
        print(piece_x, piece_y, board_x, board_y, '------->')
        distance = math.sqrt((piece_x - board_x)**2 + (piece_y - board_y)**2)
        #生成一个随机按压点,防止被Ban
        if DEBUG:
            debug.save_debug_screenshot(ntime, img, piece_x, piece_y, board_x,
                                        board_y)
            debug.backup_screenshot(ntime)
        press_point = (random.randint(*config['swipe']['x']),
                       random.randint(*config['swipe']['y']))
        #跳跃
        jump(distance, press_point, config['press_ratio'])
        #休息,停留(注意应该理论上是可以休息1~2秒的挣个连续区间,而不是离散区间)
        time.sleep(random.randrange(1, 3))