Commits

przemoli committed 540433c

Displaying empty window

  • Participants
  • Parent commits 9646828
  • Tags basic1.0

Comments (0)

Files changed (1)

 from pygame.locals import *
  
 class App:
+    def __init__(self):
+        self._running = True
+        self._display_surf = None
+        self.size = self.weight, self.height = 640, 400
+ 
+    def on_init(self):
+        pygame.init()
+        self._display_surf = pygame.display.set_mode(self.size, pygame.HWSURFACE | pygame.DOUBLEBUF)
+        self._running = True
+ 
+    def on_event(self, event):
+        if event.type == pygame.QUIT:
+            self._running = False
+    def on_loop(self):
+        pass
+    def on_render(self):
+        pass
+    def on_cleanup(self):
+        pygame.quit()
+ 
     def on_execute(self):
-        pass
+        if self.on_init() == False:
+            self._running = False
+ 
+        while( self._running ):
+            for event in pygame.event.get():
+                self.on_event(event)
+            self.on_loop()
+            self.on_render()
+        self.on_cleanup()
  
 if __name__ == "__main__" :
     theApp = App()