示例#1
0
import cv2, imutils, os
from src.screen_processor import MapleScreenCapturer
from src.screen_processor import StaticImageProcessor
from src.keystate_manager import KeyboardInputManager
import src.directinput_constants
import numpy as np, time

screencap = MapleScreenCapturer()
scrp = StaticImageProcessor(screencap)
scrp.update_image()
area = scrp.get_minimap_rect()
key_mgr = KeyboardInputManager()

testkey = src.directinput_constants.DIK_A

while True:
    scrp.update_image(set_focus=False)
    minimap_image = scrp.bgr_img[area[1]:area[1] + area[3],
                                 area[0]:area[0] + area[2]]
    playerpos = scrp.find_player_minimap_marker(area)
    if playerpos:
        cv2.circle(minimap_image, playerpos, 4, (255, 0, 0), -1)
    regular_find = imutils.resize(minimap_image, width=400)
    cv2.imshow("s to start measuring", regular_find)

    #print("regular", playerpos)
    #print("templ", playerpos_templ)

    inp = cv2.waitKey(1)
    if inp == ord("q"):
        cv2.destroyAllWindows()
from src.screen_processor import MapleScreenCapturer, StaticImageProcessor
import cv2, numpy as np
mcap = MapleScreenCapturer()

scrp = StaticImageProcessor(mcap)
player_marker = np.array([68, 221, 255])
scrp.update_image()
area = scrp.get_minimap_rect()
print(area)
while True:
    scrp.update_image(set_focus=False)
    cropped = scrp.bgr_img[area[1]:area[1] + area[3],
                           area[0]:area[0] + area[2]]

    mask = cv2.inRange(cropped, player_marker, player_marker)
    td = np.transpose(np.where(mask > 0)).tolist()
    print(len(td))
    """if len(td) > 0:
        avg_x = 0
        avg_y = 0
        totalpoints = 0
        for coord in td:
            avg_y += coord[0]
            avg_x += coord[1]
            totalpoints += 1
        avg_y = int(avg_y / totalpoints)
        avg_x = int(avg_x / totalpoints)
        return avg_x, avg_y"""
    cv2.imshow("", mask)
    dt = cv2.waitKey(1)
    if dt == ord("q"):
示例#3
0
from src.player_controller import PlayerController
from src.keystate_manager import KeyboardInputManager
import time
from src.screen_processor import MapleScreenCapturer
from src.screen_processor import StaticImageProcessor
from win32gui import SetForegroundWindow

wcap = MapleScreenCapturer()
scrp = StaticImageProcessor(wcap)
hwnd = wcap.ms_get_screen_hwnd()
kbd_mgr = KeyboardInputManager()
player_cntrlr = PlayerController(kbd_mgr, scrp)

SetForegroundWindow(hwnd)
time.sleep(0.5)
scrp.update_image()
print(scrp.get_minimap_rect())
print(scrp.find_player_minimap_marker())
player_cntrlr.update()

print(player_cntrlr.x, player_cntrlr.y)

#player_cntrlr.moonlight_slash_sweep_move(player_cntrlr.x + 100)
player_cntrlr.optimized_horizontal_move(player_cntrlr.x + 1)
#player_cntrlr.jumpr_double()
#player_cntrlr.jumpr_glide()
print(player_cntrlr.x, player_cntrlr.y)

import matplotlib.pyplot as plt, time
from src.screen_processor import MapleScreenCapturer, StaticImageProcessor
from src.directinput_constants import DIK_ALT, DIK_UP
from src.keystate_manager import KeyboardInputManager

cap = MapleScreenCapturer()
scrp = StaticImageProcessor(cap)
scrp.update_image(set_focus=True)
rect = scrp.get_minimap_rect()

inp = KeyboardInputManager()

start_delay = 0.5
increment = -0.05
plot_data = []
while start_delay > 0:
    scrp.update_image(set_focus=False)
    current_y = scrp.find_player_minimap_marker(rect)[1]
    start_time = time.time()
    inp.single_press(DIK_ALT)
    time.sleep(start_delay)
    inp.single_press(DIK_UP)
    time.sleep(0.01)
    inp.single_press(DIK_UP)
    y_list = []
    while abs(time.time() - start_time) < 3:
        scrp.update_image(set_focus=False)
        y_list.append(scrp.find_player_minimap_marker(rect)[1])
    plot_data.append((round(start_delay, 2), abs(current_y - min(y_list))))
    print("Delay: %f distance: %d" %
          (round(start_delay, 2), abs(current_y - min(y_list))))