def find_dino(): left_up = [0, 0] right_bottom = [w // 2, h] diff = [right_bottom[0] - left_up[0], right_bottom[1] - left_up[1]] dino_scan = snp.locateCenterOnScreen('dino_head.jpeg', threshold=0.8, region=left_up + diff) return dino_scan
def order(customer): gui.moveTo(customer, customer_y) temp = None while temp == None: for item in menu: temp = snp.locateCenterOnScreen(item, region=(customer, customer_y, 100, 100)) if (temp != None): return menu.index(item) + 1
def locate_moles_and_hit(coord_of_bases): for i in coord_of_bases: p = snp.locateCenterOnScreen('mole.png', threshold=0.87, region=(i[0] - 10, i[1] + i[3] - 120, 150, 130)) # i,region = (left,top,w,h) # mole.png = 133*113 if p != None: pyautogui.click(p[0], p[1])
def empty_dishes(): first = True for pos in customer_pos: count = 0 temp = None while not temp: temp = snp.locateCenterOnScreen('sushi/empty.png', threshold=0.9, region=(pos, customer_y + 150, 120, 80)) count += 1 time.sleep(1) gui.click(temp)
def buy_ingre(ingrediant=None, emergency=False): global rice, nori, roe, salmon, shrimp, eel, score trig = False if emergency: gui.click(phone) time.sleep(0.2) if (ingrediant == 'rice'): temp = snp.locateCenterOnScreen('sushi/phone_rice.png') gui.click(temp) item = None while item == None: item = snp.locateCenterOnScreen('sushi/phone_rice_2.png', threshold=0.9) gui.click(item) gui.click(temp) rice += 10 score -= 100 else: if (ingrediant == 'nori'): nori += 10 score -= 100 pic = 'sushi/phone_nori.png' elif (ingrediant == 'roe'): roe += 10 score -= 200 pic = 'sushi/phone_roe.png' elif (ingrediant == 'salmon'): salmon += 5 score -= 300 pic = 'sushi/phone_salmon.png' elif (ingrediant == 'shrimp'): shrimp += 5 pic = 'sushi/phone_shrimp.png' elif (ingrediant == 'eel'): eel += 5 pic = 'sushi/phone_eel.png' else: pass temp = snp.locateCenterOnScreen('sushi/phone_topping.png') gui.click(temp) item = None while item == None: item = snp.locateCenterOnScreen(pic) gui.click(item) gui.click(temp[0], temp[1] + 80) time.sleep(6) return True if (nori < 5): gui.click(phone) time.sleep(0.2) temp = snp.locateCenterOnScreen('sushi/phone_topping.png') gui.click(temp) item = None while item == None: item = snp.locateCenterOnScreen('sushi/phone_nori.png') gui.click(item) gui.click(temp[0], temp[1] + 20) nori += 10 score -= 100 trig = True if (roe < 6): gui.click(phone) time.sleep(0.2) temp = snp.locateCenterOnScreen('sushi/phone_topping.png') gui.click(temp) item = None while item == None: item = snp.locateCenterOnScreen('sushi/phone_roe.png') gui.click(item) gui.click(temp[0], temp[1] + 20) roe += 10 score -= 200 trig = True if (salmon < 4): gui.click(phone) time.sleep(0.2) temp = snp.locateCenterOnScreen('sushi/phone_topping.png') gui.click(temp) item = None while item == None: item = snp.locateCenterOnScreen('sushi/phone_salmon.png') gui.click(item) gui.click(temp[0], temp[1] + 20) salmon += 5 score -= 300 trig = True if (shrimp < 4): gui.click(phone) time.sleep(0.2) temp = snp.locateCenterOnScreen('sushi/phone_topping.png') gui.click(temp) item = None while item == None: item = snp.locateCenterOnScreen('sushi/phone_shrimp.png') gui.click(item) gui.click(temp[0], temp[1] + 20) shrimp += 5 trig = True if (eel < 4): gui.click(phone) time.sleep(0.2) temp = snp.locateCenterOnScreen('sushi/phone_topping.png') gui.click(temp) item = None while item == None: item = snp.locateCenterOnScreen('sushi/phone_eel.png') gui.click(item) gui.click(temp[0], temp[1] + 20) eel += 5 trig = True if (rice < 8): gui.click(phone) time.sleep(0.2) temp = snp.locateCenterOnScreen('sushi/phone_rice.png') gui.click(temp) item = None while item == None: item = snp.locateCenterOnScreen('sushi/phone_rice_2.png', threshold=0.9) gui.click(item) gui.click(temp) rice += 10 score -= 100 trig = True return trig
def click_center(pic, threshold=0.87): temp = snp.locateCenterOnScreen(pic, threshold=threshold) gui.click(temp[0], temp[1])
def find_ingre(pic, num=1): temp = snp.locateCenterOnScreen(pic, region=(ingredient_x, ingredient_y, 200, 460)) gui.click(temp, clicks=num, interval=0.1, pause=0.1, _pause=True)
gui.click(sushi_done_x, sushi_done_y, pause=2, _pause=True) ########################### main ############################# # enter game click_center('sushi/play.png') time.sleep(0.2) click_center('sushi/go.png') time.sleep(0.2) # init position print('calculating position') top = snp.locateOnScreen('sushi/music.png') phone = snp.locateCenterOnScreen('sushi/phone.png') ingredient_x = top[0] + 20 ingredient_y = top[1] + 330 sushi_done_x = top[0] + 270 sushi_done_y = top[1] + 395 customer_y = top[1] + 40 customer_pos = [] customer_pos.append(top[0] + 60) customer_pos.append(top[0] + 180) customer_pos.append(top[0] + 310) customer_pos.append(top[0] + 430) customer_pos.append(top[0] + 550) # start game start = time.time()
print("Clutch 1") if i > 2500 and change == 1: jump_pos[0] = jump_pos[0] + 5 jump_pos_corner[0] = jump_pos_corner[0] + 5 change = 2 print("Clutch 2") if i > 5000 and change == 2: jump_pos[0] = jump_pos[0] + 2 jump_pos_corner[0] = jump_pos_corner[0] + 2 change = 3 print("Clutch 3") jump_scan = snp.locateCenterOnScreen('jump_blank.jpeg', threshold=0.3, region=jump_pos + jump_diff) if jump_scan == None: #Not blank pyautogui.press('space') dino_scan = snp.locateCenterOnScreen('dino_head.jpeg', threshold=0.5, region=dino_high + dino_diff) if dino_scan != None: #Is Head #print("detec dino head") under_dino_scan = snp.locateCenterOnScreen('under_dino.jpg', threshold=0.4, region=under_dino + under_diff)