-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmousetargettracker.py
54 lines (43 loc) · 2.05 KB
/
mousetargettracker.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import pygame
import random
import os
import pyautogui
import time
import asyncio
base = os.path.dirname(os.path.abspath(__file__))
def sanitize_path(path):
return os.path.join(base, path)
from calculated_vars import *
class mouseTarget:
def __init__ (self):
self.target = pygame.image.load(sanitize_path('Images/crosshair.png'))
self.SCALE_SIZE = (75, 75)
self.target = pygame.transform.scale(self.target, self.SCALE_SIZE)
self.bx = WIDTH // 2
self.by = HEIGHT // 2
def update_target(self, window, mouse_pos, joystick):
if joystick:
# if (joystick and joystick.get_axis(2) <= -JOYSTICK_THRESHOLD):
# self.bx = max(0, self.bx - 1)
# if (joystick and joystick.get_axis(2) >= JOYSTICK_THRESHOLD):
# self.bx = max(0, self.bx + 1)
# if (joystick and joystick.get_axis(3) <= -JOYSTICK_THRESHOLD):
# self.by = max(0, self.by - 1)
# if (joystick and joystick.get_axis(3) >= JOYSTICK_THRESHOLD):
# self.by = max(0, self.by + 1)
if abs(joystick.get_axis(2)) > JOYSTICK_THRESHOLD / 5:
if FPS:
self.bx = min(max(0, self.bx + (joystick.get_axis(2) * 12.5 / FPS * SQUARE_SIZE)), WIDTH)
else:
self.bx = min(max(0, self.bx + (joystick.get_axis(2) * 12.5 * UCFD.delay * SQUARE_SIZE)), WIDTH)
if abs(joystick.get_axis(3)) > JOYSTICK_THRESHOLD / 5:
if FPS:
self.by = min(max(0, self.by + (joystick.get_axis(3) * 12.5 / FPS * SQUARE_SIZE)), HEIGHT)
else:
self.by = min(max(0, self.by + (joystick.get_axis(3) * 12.5 * UCFD.delay * SQUARE_SIZE)), HEIGHT)
updated_mouse_pos = (self.bx - 40, self.by - 40)
window.blit(self.target, updated_mouse_pos)
else:
mouse_pos = pygame.mouse.get_pos()
updated_mouse_pos = (mouse_pos[0] - 40, mouse_pos[1] - 40)
window.blit(self.target, updated_mouse_pos)