From 72d08f5c5c38da987a496f344e88e51fb956d6a6 Mon Sep 17 00:00:00 2001 From: Joe Wreschnig Date: Thu, 18 Mar 2010 01:36:08 -0700 Subject: [PATCH 1/1] If a ChangeDirection, ChangeSpeed, Accel, or Wait action takes 0 frames, do it immediately and continue. --- bulletml/impl.py | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/bulletml/impl.py b/bulletml/impl.py index f3d7e12..8508896 100644 --- a/bulletml/impl.py +++ b/bulletml/impl.py @@ -172,7 +172,12 @@ class Action(object): elif isinstance(action, parser.ChangeSpeed): frames, (speed, type) = action(s_params, rank) self.speed_frames = frames - if type == "sequence": + if frames <= 0: + if type == "absolute": + owner.speed = speed + elif type == "relative": + owner.speed += speed + elif type == "sequence": self.speed = speed elif type == "relative": self.speed = speed / frames @@ -188,21 +193,28 @@ class Action(object): else: if type == "absolute": direction -= owner.direction - elif type == "relative": - direction = direction - else: + elif type != "relative": # aim or default self.aiming = True direction += owner.aim - owner.direction - self.direction = ( - (direction + math.pi) % PI_2 - math.pi) / frames + # Normalize to [-pi, pi). + direction = (direction + math.pi) % PI_2 - math.pi + if frames <= 0: + owner.direction += direction + else: + self.direction = direction / frames elif isinstance(action, parser.Accel): frames, horizontal, vertical = action(s_params, rank) self.accel_frames = frames if horizontal: mx, type = horizontal - if type == "sequence": + if frames <= 0: + if type == "absolute": + owner.mx = mx + elif type == "relative": + owner.mx += mx + elif type == "sequence": self.mx = mx elif type == "absolute": self.mx = (mx - owner.mx) / frames @@ -210,7 +222,12 @@ class Action(object): self.mx = mx / frames if vertical: my, type = vertical - if type == "sequence": + if frames <= 0: + if type == "absolute": + owner.my = my + elif type == "relative": + owner.my += my + elif type == "sequence": self.my = my elif type == "absolute": self.my = (my - owner.my) / frames @@ -228,7 +245,8 @@ class Action(object): elif isinstance(action, parser.Wait): self.wait_frames = action(s_params, rank) - break + if self.wait_frames: + break elif isinstance(action, parser.Vanish): owner.vanish() -- 2.30.2