Add displaying of a simple window.
authorSimon Cross <hodgestar@gmail.com>
Sun, 4 Sep 2016 13:34:30 +0000 (15:34 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sun, 4 Sep 2016 13:34:30 +0000 (15:34 +0200)
run_game.py
run_game.pyw
tabakrolletjie/__main__.py [deleted file]
tabakrolletjie/engine.py
tabakrolletjie/main.py [new file with mode: 0644]
tabakrolletjie/scenes/menu.py

index 31e7bb0afecf44d990b18589c94df32a41213d75..11e135909260f53414f46c89164160e2a3013639 100644 (file)
@@ -1,3 +1,4 @@
-import tabakrolletjie.__main__
+from tabakrolletjie.main import main
+
 if __name__ == "__main__":
-    tabakrolletjie.__main__.main()
+    main()
index 1a6f51f94c835bb58038c4878d59955e6a18a014..11e135909260f53414f46c89164160e2a3013639 100644 (file)
@@ -1,3 +1,4 @@
-import yourgameshortname.main
+from tabakrolletjie.main import main
+
 if __name__ == "__main__":
-    yourgameshortname.main.main()
+    main()
diff --git a/tabakrolletjie/__main__.py b/tabakrolletjie/__main__.py
deleted file mode 100644 (file)
index dbb20cd..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-
-def main():
-    """ your app starts here
-    """
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..eee88b761dcc168c07c1d8fe85731af1b00a7962 100644 (file)
@@ -0,0 +1,32 @@
+""" Engine for moving controll scenes and tranistions between them.
+"""
+
+import pygame.display
+import pygame.event
+import pygame.time
+
+import pygame.locals as pgl
+
+from .constants import FPS
+
+
+class Engine(object):
+    def __init__(self, screen, scene):
+        self._screen = screen
+        self._scene = scene
+
+    def run(self):
+        clock = pygame.time.Clock()
+
+        while True:
+            events = pygame.event.get()
+            for ev in events:
+                if ev.type == pgl.QUIT:
+                    return
+                else:
+                    pass  # TODO: send to scene
+
+            # TODO: render scene
+            pygame.display.flip()
+
+            clock.tick(FPS)
diff --git a/tabakrolletjie/main.py b/tabakrolletjie/main.py
new file mode 100644 (file)
index 0000000..77af827
--- /dev/null
@@ -0,0 +1,24 @@
+""" Run tabakrolletjie.
+"""
+
+import pygame
+import pygame.locals as pgl
+
+from .constants import SCREEN_SIZE, TITLE
+from .engine import Engine
+from .scenes.menu import MenuScene
+
+
+def main():
+    pygame.display.init()
+    pygame.font.init()
+
+    pygame.display.set_mode(SCREEN_SIZE, pgl.SWSURFACE)
+    pygame.display.set_caption(TITLE)
+    # TODO: set an icon
+
+    screen = pygame.display.get_surface()
+    scene = MenuScene()
+    engine = Engine(screen, scene)
+
+    engine.run()
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e7092d58637889e3941e939841cfad24e1a6d52b 100644 (file)
@@ -0,0 +1,4 @@
+""" Menu scene. """
+
+class MenuScene(object):
+    pass