From: Skullheadx <704277@pdsb.net> Date: Tue, 24 Jan 2023 22:07:31 +0000 (-0500) Subject: basic window display X-Git-Url: http://git.skullheadx.com/nixos/static/gitweb.css?a=commitdiff_plain;h=765362a492bd41cec9cf50bb3ad8ce5469e3a6d1;p=Sorting.git basic window display --- diff --git a/display.py b/display.py new file mode 100644 index 0000000..17038d3 --- /dev/null +++ b/display.py @@ -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)