From: Simon Cross Date: Sun, 4 Sep 2016 13:34:30 +0000 (+0200) Subject: Add displaying of a simple window. X-Git-Tag: tabakrolletjie-v1.0.0~271 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=a52f1e6d05d8dc5c4c1d55470137fed81fb5ce76;p=tabakrolletjie.git Add displaying of a simple window. --- diff --git a/run_game.py b/run_game.py index 31e7bb0..11e1359 100644 --- a/run_game.py +++ b/run_game.py @@ -1,3 +1,4 @@ -import tabakrolletjie.__main__ +from tabakrolletjie.main import main + if __name__ == "__main__": - tabakrolletjie.__main__.main() + main() diff --git a/run_game.pyw b/run_game.pyw index 1a6f51f..11e1359 100644 --- a/run_game.pyw +++ b/run_game.pyw @@ -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 index dbb20cd..0000000 --- a/tabakrolletjie/__main__.py +++ /dev/null @@ -1,4 +0,0 @@ - -def main(): - """ your app starts here - """ diff --git a/tabakrolletjie/engine.py b/tabakrolletjie/engine.py index e69de29..eee88b7 100644 --- a/tabakrolletjie/engine.py +++ b/tabakrolletjie/engine.py @@ -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 index 0000000..77af827 --- /dev/null +++ b/tabakrolletjie/main.py @@ -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() diff --git a/tabakrolletjie/scenes/menu.py b/tabakrolletjie/scenes/menu.py index e69de29..e7092d5 100644 --- a/tabakrolletjie/scenes/menu.py +++ b/tabakrolletjie/scenes/menu.py @@ -0,0 +1,4 @@ +""" Menu scene. """ + +class MenuScene(object): + pass