-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbotmode.py
More file actions
30 lines (24 loc) · 778 Bytes
/
botmode.py
File metadata and controls
30 lines (24 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import cv2
from PIL import ImageGrab
import numpy as np
import pyautogui
# Grab a certain region of the screen
def grab_screen(region=None):
img = ImageGrab.grab(bbox=region)
return img
while True:
# Capture game screen of interest and convert it to a np array
frame = np.array(grab_screen((800, 400, 1200, 600)))
danger = np.array(grab_screen((1014, 500, 1020, 501)))
# Convert RGB -> BGR
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
danger = cv2.cvtColor(danger, cv2.COLOR_RGB2BGR)
for x in danger[0]:
if x[0] == 83:
print("Danger")
pyautogui.press('space')
print("Jump")
cv2.imshow('frame', danger)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cv2.destroyAllWindows()