projects
/
python-bulletml.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bullet.FromDocument: Abstract weird constructor handling.
[python-bulletml.git]
/
bulletml-runner
diff --git
a/bulletml-runner
b/bulletml-runner
index
21ba80e
..
faaf9e0
100755
(executable)
--- a/
bulletml-runner
+++ b/
bulletml-runner
@@
-7,6
+7,19
@@
import time
import pygame
import bulletml
import pygame
import bulletml
+import bulletml.bulletyaml
+
+try:
+ import yaml
+except ImportError:
+ yaml = None
+
+try:
+ import psyco
+except ImportError:
+ pass
+else:
+ psyco.full()
def main(argv):
if not argv:
def main(argv):
if not argv:
@@
-23,8
+36,8
@@
def main(argv):
while True:
filename = argv[file_idx % len(argv)]
while True:
filename = argv[file_idx % len(argv)]
- doc = bulletml.BulletML(open(filename, "rU"))
- source = bulletml.Bullet.FromDoc(
+ doc = bulletml.BulletML
.FromDocument
(open(filename, "rU"))
+ source = bulletml.Bullet.FromDoc
ument
(
doc, x=150, y=150, target=target, rank=0.5)
active = set([source])
doc, x=150, y=150, target=target, rank=0.5)
active = set([source])
@@
-58,8
+71,10
@@
def main(argv):
elif event.key == pygame.K_RETURN:
newfile = True
elif event.key == pygame.K_s:
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)
+ actions = [act([], 0.5) for act in doc.actions]
+ source = bulletml.Bullet(
+ x=150, y=150, target=target,
+ actions=actions, rank=0.5)
source.vanished = True
active.add(source)
target.x, target.y = pygame.mouse.get_pos()
source.vanished = True
active.add(source)
target.x, target.y = pygame.mouse.get_pos()
@@
-82,12
+97,13
@@
def main(argv):
frames += 1
if frames % 100 == 0:
frames += 1
if frames % 100 == 0:
- seconds_per_bullet = elapsed / count
- bullets_per_second = count / elapsed
print " Processing: %04d: %d bullets, %d active." % (
frames, total, count)
print " Processing: %04d: %d bullets, %d active." % (
frames, total, count)
- print " %g seconds per bullet (60Hz max: %g)." % (
- seconds_per_bullet, bullets_per_second / 60)
+ if elapsed:
+ seconds_per_bullet = elapsed / count
+ bullets_per_second = count / elapsed
+ print " %g seconds per bullet (60Hz max: %g)." % (
+ seconds_per_bullet, bullets_per_second / 60)
screen.fill([0, 0, 0])
for obj in active:
screen.fill([0, 0, 0])
for obj in active: