Test runner improvements.
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Tue, 16 Mar 2010 08:50:46 +0000 (01:50 -0700)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Tue, 16 Mar 2010 08:50:46 +0000 (01:50 -0700)
bulletml-runner

index 7ad5addd678ada824c88385ed2a08d625ea90231..fc49988296b8d92a0d4aff88a6d66a0f2c122187 100755 (executable)
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 
+import os
 import sys
 
 import pygame
@@ -7,21 +8,21 @@ import pygame
 import bulletml
 
 def main(argv):
+    if not argv:
+        raise SystemExit("Usage: %s filename ..." % sys.argv[0])
+
     pygame.display.init()
     screen = pygame.display.set_mode([600, 600], pygame.DOUBLEBUF)
     bullet = pygame.Surface([3, 3])
     bullet.fill([255, 0, 0])
-    filename = argv[0]
     clock = pygame.time.Clock()
     target = bulletml.Bullet()
 
     file_idx = 0
 
-    if not argv:
-        raise SystemExit
-
     while True:
-        doc = bulletml.BulletML(open(argv[file_idx % len(argv)], "rU"))
+        filename = argv[file_idx % len(argv)]
+        doc = bulletml.BulletML(open(filename, "rU"))
         source = bulletml.Bullet.FromDoc(
             doc, x=150, y=150, target=target, rank=0.5)
                                          
@@ -34,6 +35,8 @@ def main(argv):
         paused = False
         newfile = False
 
+        pygame.display.set_caption(os.path.basename(filename))
+
         while active and not newfile:
             go = False
 
@@ -53,6 +56,11 @@ def main(argv):
                         newfile = True
                     elif event.key == pygame.K_RETURN:
                         newfile = True
+                    elif event.key == pygame.K_s:
+                        source = bulletml.Bullet.FromDoc(
+                            doc, x=150, y=150, target=target, rank=0.5)
+                        source.vanished = True
+                        active.add(source)
             target.x, target.y = pygame.mouse.get_pos()
             target.x /= 2
             target.y /= 2