X-Git-Url: https://git.yukkurigames.com/?p=python-bulletml.git;a=blobdiff_plain;f=bulletml%2Fimpl.py;h=358aae1a1c192a60d8c4567aa5ddf63b6821a321;hp=ad39e7bd0d047abcc5917c6829e5fabd7fa26e84;hb=62bfd556a69becf6b23715a150accac703af9058;hpb=8134626d4517fcc582b322652243835e407524a9 diff --git a/bulletml/impl.py b/bulletml/impl.py index ad39e7b..358aae1 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: @@ -145,16 +145,28 @@ class Action(object): elif type == "relative": # The reference Noiz implementation uses # prvFireSpeed here, but the standard is - # pretty clear -- "0 means that the direction - # of this fire and the direction of the bullet - # are the same". + # pretty clear -- "In case of the type is + # "relative", ... the speed is relative to the + # speed of this bullet." speed += owner.speed else: 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):