-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathExtraElements.py
149 lines (119 loc) · 5.52 KB
/
ExtraElements.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import pygame
import time
from threading import *
import SortingAlgorithm
class Clock(Thread):
def __init__(self,screen,CordinateX,CordinateY,font,*args):
Thread.__init__(self)
self.screen = screen
self.CordinateX=CordinateX
self.CordinateY=CordinateY
self.ClockComplete=False
self.font=font
self.running=True
self.Clock=[0,0]
self.printTime= "00:00"
def run(self):
try:
while(SortingAlgorithm.RunClock):
pygame.font.init()
myfont = pygame.font.SysFont('Comic Sans MS', self.font)
self.textsurface = myfont.render(self.printTime, False, (255, 255, 255))
self.screen.blit(self.textsurface, (self.CordinateX-50, self.CordinateY))
myfont = pygame.font.SysFont('Comic Sans MS', self.font)
self.textsurface = myfont.render(" Time Escaped:", False, (255, 255, 255))
self.screen.blit(self.textsurface, (self.CordinateX-120, self.CordinateY-30))
time.sleep(1)
if not SortingAlgorithm.RunClock:
break
textsurface = myfont.render(self.printTime, False, (0, 0, 0))
self.screen.blit(textsurface, (self.CordinateX-50, self.CordinateY))
if not self.ClockComplete:
if self.Clock[1]==59:
self.Clock[0]+=1
self.Clock[1]=0
if len(str(self.Clock[0])) == 1:
self.printTime = '0' + str(self.Clock[0])
else:
self.printTime = str(self.Clock[0])
self.printTime=str(self.Clock[0])+':'+ '0' + str(self.Clock[1])
else:
self.Clock[1]+=1
if len(str(self.Clock[0])) == 1 and len(str(self.Clock[1]))==1:
self.printTime='0'+str(self.Clock[0])+':' +'0' + str(self.Clock[1])
elif len(str(self.Clock[1]))==1:
self.printTime=str(self.Clock[0])+':'+ '0' + str(self.Clock[1])
elif len(str(self.Clock[0])) == 1:
self.printTime = '0'+str(self.Clock[0]) + ':' + str(self.Clock[1])
else:
self.printTime = str(self.Clock[0])+ ':' + str(self.Clock[1])
myfont = pygame.font.SysFont('Comic Sans MS', self.font)
textsurface = myfont.render(self.printTime, False, (255, 255, 255))
self.screen.blit(textsurface, (self.CordinateX-50, self.CordinateY))
except:
pass
class MainMenuButton(Thread):
def __init__(self,screen,CordinateX,CordinateY,*args):
Thread.__init__(self)
self.X=CordinateX
self.Y=CordinateY
self.screen = screen
self.CordinateX=CordinateX
self.CordinateY=CordinateY
self.ClockComplete=False
def run(self):
try:
while(True):
self.pos=pygame.mouse.get_pos()
self.OnMainMenuButton=False
if self.pos[0] > self.X and self.pos[0] < self.X + 240 and self.pos[1] > self.Y and self.pos[1] < self.Y + 35:
self.OnMainMenuButton=True
pygame.font.init()
if self.OnMainMenuButton == False:
pygame.draw.rect(self.screen,(255,255,255),(self.X,self.Y,240,35))
myfont = pygame.font.SysFont('Comic Sans MS', 20)
textsurface = myfont.render("Go Back to Main Menu", False, (0, 0, 0))
self.screen.blit(textsurface, (self.X+17, self.Y))
else:
pygame.draw.rect(self.screen,(0,0,0),(self.X,self.Y,240,35))
pygame.draw.rect(self.screen,(255,255,255),(self.X,self.Y,240,35),3)
myfont = pygame.font.SysFont('Comic Sans MS', 20)
textsurface = myfont.render("Go Back to Main Menu", False, (255, 255, 255))
self.screen.blit(textsurface, (self.X+17, self.Y))
pygame.display.update()
except:
pass
class OperationsDone:
def __init__(self,NoOfOperations,screen,X,Y):
try:
self.NoOfOperations=NoOfOperations
self.screen=screen
self.X=X
self.Y=Y
pygame.font.init()
myfont = pygame.font.SysFont('Comic Sans MS', 20)
textsurface = myfont.render("Sorting Completed.", False, (255, 255, 255))
self.screen.blit(textsurface, (self.X , self.Y))
myfont = pygame.font.SysFont('Comic Sans MS', 20)
textsurface = myfont.render("Operations Performed: "+str(self.NoOfOperations), False, (255, 255, 255))
self.screen.blit(textsurface, (self.X, self.Y+40))
except:
pass
class ExitText(Thread):
def __init__(self,screen,CordinateX,CordinateY,*args):
Thread.__init__(self)
self.X=CordinateX
self.Y=CordinateY
self.screen = screen
self.CordinateX=CordinateX
self.CordinateY=CordinateY
self.ClockComplete=False
def run(self):
try:
while(True):
pygame.font.init()
myfont = pygame.font.SysFont('Comic Sans MS', 20)
textsurface = myfont.render("Press Esc to Exit.", False, (255, 255, 255))
self.screen.blit(textsurface, (self.X+17, self.Y))
except:
pass