Closed AlexTheM8 closed 2 years ago
This will also be useful to decrease the size of the image used to analyze
The following code, accurately captures the game window:
def enumHandler(hwnd, lParam):
global window
name = win32gui.GetWindowText(hwnd)
if 'Dolphin' in name and 'Super Monkey Ball' in name:
window = hwnd
if __name__ == '__main__':
window = None
win32gui.EnumWindows(enumHandler, None)
if window is not None:
border_x, border_y = 9, 39
x, y, w, h = win32gui.GetWindowRect(window)
w -= x
h -= y
x = int(x * 1.25) + border_x + 1
y = int(y * 1.25) + border_y
w = int(w * 1.25) - (border_x * 2)
h = int(h * 1.25) - (border_y + 8)
monitor = {"top": y, "left": x, "width": w, "height": h}
else:
print('Error')
However, there is a new problem with the reference images not being the correct size. Investigate resizing these images.
This would potentially save 0.013 sec/step which translates to approximately one extra frame per second. Difference may be negligible.
EDIT: New run finds a time save of ~0.035 sec/step which could be an extra two frames per second
Currently, the game screen capture is hard-coded in place, but to allow a more flexible user experience, have it find the actual location and take a screenshot that way