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
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
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
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()