From ad4a740bd87e520bc0b13c0db2c332aba54cf68f Mon Sep 17 00:00:00 2001 From: Joe Wreschnig Date: Thu, 18 Mar 2010 00:18:42 -0700 Subject: [PATCH] Prevent divide by zero when the elapsed time is too small. --- bulletml-runner | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bulletml-runner b/bulletml-runner index de0fa5a..ec6007b 100755 --- a/bulletml-runner +++ b/bulletml-runner @@ -85,12 +85,13 @@ def main(argv): 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 " %g seconds per bullet (60Hz max: %g)." % ( - seconds_per_bullet, bullets_per_second / 60) + if elapsed: + print " %g seconds per bullet (60Hz max: %g)." % ( + seconds_per_bullet = elapsed / count + bullets_per_second = count / elapsed + seconds_per_bullet, bullets_per_second / 60) screen.fill([0, 0, 0]) for obj in active: -- 2.30.2