#!/usr/bin/env python
+import os
import sys
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)
paused = False
newfile = False
+ pygame.display.set_caption(os.path.basename(filename))
+
while active and not newfile:
go = False
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