X-Git-Url: https://git.yukkurigames.com/?p=python-bulletml.git;a=blobdiff_plain;f=bulletml%2Fimpl.py;h=26b95804230b9f76877f5d41bfdf5ed841b1443f;hp=ad39e7bd0d047abcc5917c6829e5fabd7fa26e84;hb=16023be19df43f8b8acc4671e0fabdeffb0e720a;hpb=566db5262d961975a4aa4c5896d99773f9d3dd37 diff --git a/bulletml/impl.py b/bulletml/impl.py index ad39e7b..26b9580 100644 --- a/bulletml/impl.py +++ b/bulletml/impl.py @@ -125,7 +125,7 @@ class Action(object): break elif isinstance(action, (parser.FireDef, parser.FireRef)): - direction, speed, actions = action(self.params, rank) + direction, speed, actions, offset = action(self.params, rank) if direction: direction, type = direction if type == "aim" or type is None: @@ -153,8 +153,20 @@ class Action(object): speed = 1 self.previous_fire_speed = speed - bullet = Bullet(owner.x, owner.y, direction, speed, - owner.target, actions, self, rank) + x, y = owner.x, owner.y + if offset: + off_x, off_y = offset(self.params, rank) + if offset.type == "relative": + sin = math.sin(direction) + cos = math.cos(direction) + x += cos * off_x + sin * off_y + y += sin * off_x - cos * off_y + else: + x += off_x + y += off_y + + bullet = Bullet( + x, y, direction, speed, owner.target, actions, self, rank) created.append(bullet) elif isinstance(action, parser.ChangeSpeed):