FireDef.__call__: Minor optimizations.
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Sat, 24 Apr 2010 08:43:07 +0000 (01:43 -0700)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Sat, 24 Apr 2010 08:43:07 +0000 (01:43 -0700)
bulletml/parser.py

index 150ca4544ef53d6a43f177c7957ef709c1ccf537..1470ed37bee5959dd2496a5ffc0fe52351f686df 100644 (file)
@@ -816,15 +816,15 @@ class FireDef(object):
     def __call__(self, owner, action, params, rank, created):
         direction, speed, tags, appearance, actions = self.bullet(
             owner, action, params, rank, created)
-        if self.direction:
+        if self.direction is not None:
             direction = self.direction(params, rank)
-        if self.speed:
+        if self.speed is not None:
             speed = self.speed(params, rank)
         tags = tags.union(self.tags)
-        if self.appearance:
+        if self.appearance is not None:
             appearance = self.appearance
 
-        if direction:
+        if direction is not None:
             direction, type = direction
             if type == "aim" or type is None:
                 direction += owner.aim
@@ -836,7 +836,7 @@ class FireDef(object):
             direction = owner.aim
         action.previous_fire_direction = direction
 
-        if speed:
+        if speed is not None:
             speed, type = speed
             if type == "sequence":
                 speed += action.previous_fire_speed
@@ -851,8 +851,9 @@ class FireDef(object):
             speed = 1
         action.previous_fire_speed = speed
 
-        x, y = owner.x, owner.y
-        if self.offset:
+        x = owner.x
+        y = owner.y
+        if self.offset is not None:
             off_x, off_y = self.offset(params, rank)
             if self.offset.type == "relative":
                 s = sin(direction)