]> Skullheadx's Git Forge - Collision-Simulation.git/commitdiff
pygame window
authorSkullheadx <704277@pdsb.net>
Mon, 16 Jan 2023 22:29:44 +0000 (17:29 -0500)
committerSkullheadx <704277@pdsb.net>
Mon, 16 Jan 2023 22:29:44 +0000 (17:29 -0500)
.gitignore [new file with mode: 0644]
colours.py [new file with mode: 0644]
display.py [new file with mode: 0644]
main.py [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..57dde53
--- /dev/null
@@ -0,0 +1,10 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+.idea/
+__pycache__/
diff --git a/colours.py b/colours.py
new file mode 100644 (file)
index 0000000..370c4d9
--- /dev/null
@@ -0,0 +1,7 @@
+RED = (255, 0, 0)
+GREEN = (0, 255, 0)
+BLUE = (0, 0, 255)
+
+BLACK = (0, 0, 0)
+GRAY = (128, 128, 128)
+WHITE = (255, 255, 255)
diff --git a/display.py b/display.py
new file mode 100644 (file)
index 0000000..2bf647a
--- /dev/null
@@ -0,0 +1,38 @@
+from colours import *
+import pygame
+
+
+pygame.init()
+
+
+class Display:
+    WIDTH, HEIGHT = 640, 640
+    DIMENSIONS = pygame.Vector2(WIDTH, HEIGHT)
+    CENTER = pygame.Vector2(WIDTH / 2, HEIGHT / 2)
+
+    FPS = 60
+
+    def __init__(self, window_name="Pygame"):
+        self.is_running = False
+        pygame.display.set_caption(window_name)
+
+    def show(self):
+        screen = pygame.display.set_mode(self.DIMENSIONS)
+
+        clock = pygame.time.Clock()
+        delta = 0
+        self.is_running = True
+        while self.is_running:
+            self.update(delta)
+            self.draw(screen)
+            pygame.display.flip()
+            delta = clock.tick(self.FPS)
+        pygame.quit()
+
+    def update(self, delta):
+        for event in pygame.event.get():
+            if event.type == pygame.QUIT:
+                self.is_running = False
+
+    def draw(self, surf):
+        surf.fill(WHITE)
diff --git a/main.py b/main.py
new file mode 100644 (file)
index 0000000..ee74ed5
--- /dev/null
+++ b/main.py
@@ -0,0 +1,10 @@
+from display import Display
+
+
+def main():
+    d = Display()
+    d.show()
+
+
+if __name__ == "__main__":
+    main()