]> Skullheadx's Git Forge - Sorting.git/commitdiff
basic window display
authorSkullheadx <704277@pdsb.net>
Tue, 24 Jan 2023 22:07:31 +0000 (17:07 -0500)
committerSkullheadx <704277@pdsb.net>
Tue, 24 Jan 2023 22:07:31 +0000 (17:07 -0500)
display.py [new file with mode: 0644]

diff --git a/display.py b/display.py
new file mode 100644 (file)
index 0000000..17038d3
--- /dev/null
@@ -0,0 +1,38 @@
+import pygame
+
+pygame.init()
+
+BLACK = (0, 0, 0)
+GRAY = (128, 128, 128)
+WHITE = (255, 255, 255)
+
+
+class Display:
+    WIDTH, HEIGHT = 640, 640
+    DIMENSIONS = (WIDTH, HEIGHT)
+    FPS = 60
+
+    def __init__(self):
+        self.screen = pygame.display.set_mode(self.DIMENSIONS)
+        self.clock = pygame.time.Clock()
+
+    def show(self):
+        is_running = True
+
+        while is_running:
+            for event in pygame.event.get():
+                if event.type == pygame.QUIT:
+                    is_running = False
+
+            self.update()
+            self.draw(self.screen)
+
+            pygame.display.flip()
+
+        pygame.quit()
+
+    def update(self):
+        delta = self.clock.tick(self.FPS)
+
+    def draw(self, surf):
+        self.screen.fill(GRAY)