From: Joe Wreschnig Date: Tue, 16 Mar 2010 08:50:46 +0000 (-0700) Subject: Test runner improvements. X-Git-Url: https://git.yukkurigames.com/?a=commitdiff_plain;h=1efe1d12fc72141c05765f7db8a8e964cb6d2982;p=python-bulletml.git Test runner improvements. --- diff --git a/bulletml-runner b/bulletml-runner index 7ad5add..fc49988 100755 --- a/bulletml-runner +++ b/bulletml-runner @@ -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