-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSwitch
More file actions
34 lines (30 loc) · 970 Bytes
/
Switch
File metadata and controls
34 lines (30 loc) · 970 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
31
32
33
34
class Switch:
x = 0
y = 0
l = 0
w = 0
t = ""
ts = 5
switchedOn = False
def __init__(self, xc, yc, le, wi, te,tsz):
self.x = xc
self.y = yc
self.l = le
self.w = wi
self.t = te
self.ts = tsz
def update(self):
if(mouseX > self.x and mouseX < (self.x+self.l) and mouseY > self.y and mouseY < (self.y+self.w) and mousePressed):
self.switchedOn = True
elif((mouseX < self.x or mouseX > (self.x+self.l) or mouseY < self.y or mouseY > (self.y+self.w)) and mousePressed and mouseX < 200):
self.switchedOn = False
if(self.switchedOn == True):
fill(119,136,153);
else:
fill(255,255,255);
rect(self.x,self.y,self.l,self.w);
fill(0,0,0);
textSize(self.ts);
text(self.t,self.x+5,self.y+22);
def getData(self):
return self.switchedOn