-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
42 lines (34 loc) · 1.19 KB
/
main.py
File metadata and controls
42 lines (34 loc) · 1.19 KB
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
from sys import exit
import pygame
from settings import Settings
class SortAi:
def __init__(self):
"""Initialize Sort Visualization"""
pygame.init()
self.settings = Settings()
self.screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
self.settings.screen_width = self.screen.get_rect().width
self.settings.screen_height = self.screen.get_rect().height
self.settings.button_height = round(self.settings.screen_height * 0.04)
pygame.display.set_caption('Sort Visualization')
def mainLoop(self):
while True:
self._checkEvents()
self._updateScreen()
def _checkEvents(self):
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
elif event.type == pygame.KEYDOWN:
self._checkKeyDownEvents(event)
def _checkKeyDownEvents(self, event):
if event.key == pygame.K_q:
pygame.quit()
exit()
def _updateScreen(self):
self.screen.fill(self.settings.screen_color)
pygame.display.update()
if __name__ == "__main__":
s = SortAi()
s.mainLoop()