-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmouse_engine.py
135 lines (111 loc) · 4.46 KB
/
mouse_engine.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import math
from fast_and_trash import *
import pygame
class Mouse:
points = 0
def __init__(self, mouse_pos):
self.mouse_pos = mouse_pos
def update(self, Win_size, Default_size):
self.mouse_pos = pygame.mouse.get_pos()
self.mouse_pos = [round(self.mouse_pos[0] * (Default_size[0] / Win_size[0])),
round(self.mouse_pos[1] * (Default_size[1] / Win_size[1]))]
def in_circle(self, circle_cords, radius):
if distance_indicator(self.mouse_pos, circle_cords) < radius:
return True
else:
return False
def check_availability(self, color_name, radius, game, scroll):
scrolled_pos = [self.mouse_pos[0] + scroll.scroll[0],
self.mouse_pos[1] + scroll.scroll[1]]
collided = []
for circle in game.circles:
dist = distance_indicator(circle.center, scrolled_pos)
if dist < (radius + circle.radius):
if dist < radius or dist < circle.radius:
return False
collided.append(circle)
if collided:
# if u try placing red circle
if color_name == "red":
for circle in collided:
if circle.color == "purple":
return False
return True
# if u try placing blue circle
if color_name == "blue":
usable = False
for circle in collided:
if circle.color not in ["black", "smaragd", "red"]:
return False
else:
usable = True
if usable:
return True
else:
return False
# if u try placing green circle
if color_name == "green":
usable = [False, False]
for circle in collided:
if circle.color not in ["black", "smaragd", "red", "blue"]:
return False
elif circle.color in ["black", "smaragd"]:
usable = [True, True]
elif circle.color == "red":
usable[0] = True
else:
usable[1] = True
if usable[0] and usable[1]:
return True
else:
return False
# if u try placing yellow circle
if color_name == "yellow":
usable = [False, False]
for circle in collided:
if circle.color not in ["red", "green", "black", "smaragd"]:
return False
elif circle.color in ["black", "smaragd"]:
usable = [True, True]
elif circle.color == "red":
usable[0] = True
else:
usable[1] = True
if usable[0] and usable[1]:
return True
else:
return False
# if u try placing purple circle
if color_name == "purple":
usable = [False, False, False, False]
for circle in collided:
if circle.color not in ["red", "blue", "green", "yellow", "black", "smaragd"]:
return False
elif circle.color in ["black", "smaragd"]:
usable = [True, True, True, True]
elif circle.color == "red":
usable[0] = True
elif circle.color == "blue":
usable[1] = True
elif circle.color == "green":
usable[2] = True
else:
usable[3] = True
if usable[0] and usable[1] and usable[2] and usable[3]:
return True
else:
return False
# if u try placing smaragd circle
if color_name == "smaragd":
usable = False
for circle in collided:
if circle.color not in ["purple", "black"]:
return False
else:
usable = True
if usable:
return True
else:
return False
else:
return False