projects
/
python-bulletml.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
New example of a normal enemy pattern.
[python-bulletml.git]
/
bulletml-runner
diff --git
a/bulletml-runner
b/bulletml-runner
index
fc49988
..
21ba80e
100755
(executable)
--- a/
bulletml-runner
+++ b/
bulletml-runner
@@
-2,6
+2,7
@@
import os
import sys
import os
import sys
+import time
import pygame
import pygame
@@
-29,7
+30,7
@@
def main(argv):
active = set([source])
source.vanished = True
print filename
active = set([source])
source.vanished = True
print filename
- print " Loaded %d top-level actions." % len(source.actions)
+ print " Loaded %d top-level actions." % len(source.
_
actions)
frames = 0
total = 0
paused = False
frames = 0
total = 0
paused = False
@@
-67,6
+68,8
@@
def main(argv):
if not paused or go:
if not paused or go:
+ start = time.time()
+ count = len(active)
for obj in list(active):
new = obj.step()
total += len(new)
for obj in list(active):
new = obj.step()
total += len(new)
@@
-75,11
+78,16
@@
def main(argv):
or not (-50 < obj.x < 350)
or not (-50 < obj.y < 350)):
active.remove(obj)
or not (-50 < obj.x < 350)
or not (-50 < obj.y < 350)):
active.remove(obj)
+ elapsed = time.time() - start
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." % (
print " Processing: %04d: %d bullets, %d active." % (
- frames, total, len(active))
+ frames, total, count)
+ 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:
@@
-94,18
+102,8
@@
def main(argv):
x -= 1
y -= 1
screen.blit(bullet, [x, y])
x -= 1
y -= 1
screen.blit(bullet, [x, y])
- pygame.display.flip()
-
clock.tick(60)
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
+ pygame.display.flip()
print " Finished: %04d: %d bullets." % (frames, total)
print " Finished: %04d: %d bullets." % (frames, total)