Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/run.py
diff options
context:
space:
mode:
Diffstat (limited to 'run.py')
-rw-r--r--run.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/run.py b/run.py
new file mode 100644
index 0000000..b430d78
--- /dev/null
+++ b/run.py
@@ -0,0 +1,41 @@
+#! /usr/bin/env python
+"""Skeleton project file mainloop for new OLPCGames users"""
+import olpcgames, pygame, logging
+from olpcgames import pausescreen
+
+log = logging.getLogger( 'EnglishForFun run' )
+log.setLevel( logging.DEBUG )
+
+def main():
+ """The mainloop which is specified in the activity.py file
+
+ "main" is the assumed function name
+ """
+ size = (800,600)
+ if olpcgames.ACTIVITY:
+ size = olpcgames.ACTIVITY.game_size
+ screen = pygame.display.set_mode(size)
+
+ clock = pygame.time.Clock()
+
+ running = True
+ while running:
+ screen.fill( (0,0,128))
+ milliseconds = clock.tick(25) # maximum number of frames per second
+
+ # Event-management loop with support for pausing after X seconds (20 here)
+ events = pausescreen.get_events()
+ # Now the main event-processing loop
+ if events:
+ for event in events:
+ log.debug( "Event: %s", event )
+ if event.type == pygame.QUIT:
+ running = False
+ elif event.type == pygame.KEYDOWN:
+ if event.key == pygame.K_ESCAPE:
+ running = False
+ pygame.display.flip()
+
+if __name__ == "__main__":
+ logging.basicConfig()
+ main()