X-Git-Url: https://git.yukkurigames.com/?p=python-bulletml.git;a=blobdiff_plain;f=bulletml-runner;h=c08e3d8b0761e8958423157ffff8b4e763102cbf;hp=7ad5addd678ada824c88385ed2a08d625ea90231;hb=dc109fda65b9b15d479a80bb7e3a766074ff361e;hpb=2e2790231b49d4a2ed9299825ac0cf8121a655e2 diff --git a/bulletml-runner b/bulletml-runner index 7ad5add..c08e3d8 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 @@ -90,15 +98,6 @@ def main(argv): clock.tick(60) - for event in pygame.event.get(): - if event.type == pygame.QUIT: - raise SystemExit - elif event.type == pygame.KEYDOWN: - if event.key == pygame.K_SPACE: - paused ^= True - elif event.key == pygame.K_RIGHT: - go = True - print " Finished: %04d: %d bullets." % (frames, total) if __name__ == "__main__":