本人写的一个关于欢乐跳瓶的作弊程序,在夜神模拟器上运行的,主要拿canny写的。
如果是跳一跳其实就更容易了,因为欢乐跳瓶的界面较跳一跳来说噪声相对要多不少。
完整可运行代码下载请移步 https://download.csdn.net/download/kuroyukineko/10494650
下面贴一下大致PPT的内容和代码。
下面是纯代码,如果需要上机运行的话还需要几个匹配的模版,在下载里都打了包,这里就不贴了。
# bottle_flip_cheat
# by Kuroyukineko 2018.03.09
# Noxplayer(1280*720)_BottleFlip
import sys
import time
import math
import win32gui
import win32ui
import win32api
import win32con
import numpy as np
import cv2
import matplotlib.pyplot as plt
def beginDetect(hwnd, window_hw_para):
filename = "begindetect.jpg"
pic_capture(hwnd, filename)
#read image
img_origin = cv2.imread(filename)
img_cut_gray = cv2.cvtColor(img_origin, cv2.COLOR_BGR2GRAY)
#template
template = cv2.imread("beginTemplate.jpg", 0)
template1 = cv2.imread("beginTemplate.jpg", 0)
#w, h = template.shape[::-1]
res = cv2.matchTemplate(img_cut_gray,template,cv2.TM_CCOEFF_NORMED)
res1 = cv2.matchTemplate(img_cut_gray,template1,cv2.TM_CCOEFF_NORMED)
threshold = 0.6
loc = np.where( res >= threshold)
loc1 = np.where( res1 >= threshold)
if len(loc[0]) != 0 or len(loc1[0]) != 0:
mouse_move(window_hw_para['left'] + 280,
window_hw_para['top'] + 500)
mouse_click(0.5) #jump
time.sleep(1)
cv2.destroyAllWindows()
def ready_game():
#player locate the game window
print ("Please move the cursor on game window