Prevent divide by zero when the elapsed time is too small.
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Thu, 18 Mar 2010 07:18:42 +0000 (00:18 -0700)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Thu, 18 Mar 2010 07:18:42 +0000 (00:18 -0700)
bulletml-runner

index de0fa5a30f37cea8ab95f6884186f04265a35d1d..ec6007b5738f8e570be849629cbe6406df53943f 100755 (executable)
@@ -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: