X-Git-Url: https://git.yukkurigames.com/?p=python-bulletml.git;a=blobdiff_plain;f=bulletml%2Fimpl.py;h=8f94d5569e02e5d91b5b3e3f751cf881b96491a7;hp=26b95804230b9f76877f5d41bfdf5ed841b1443f;hb=8c89bcae073f0e3c7e58a880512c8accb863bb07;hpb=16023be19df43f8b8acc4671e0fabdeffb0e720a diff --git a/bulletml/impl.py b/bulletml/impl.py index 26b9580..8f94d55 100644 --- a/bulletml/impl.py +++ b/bulletml/impl.py @@ -145,9 +145,9 @@ 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 @@ -224,6 +224,15 @@ class Action(object): elif type == "relative": self.my = my / frames + elif isinstance(action, parser.Tag): + owner.tags.add(action.tag) + + elif isinstance(action, parser.Untag): + try: + owner.tags.remove(action.tag) + except KeyError: + pass + elif isinstance(action, parser.Wait): self.wait_frames = action(self.params, rank) break @@ -246,6 +255,7 @@ class Bullet(object): target - object with .x and .y fields for "aim" directions vanished - set to true by a action rank - game difficulty, 0 to 1, default 0.5 + tags - string tags set by the running actions Contructor Arguments: x, y, direction, speed, target, rank - same as the attributes @@ -266,6 +276,7 @@ class Bullet(object): self.vanished = False self.target = target self.rank = rank + self.tags = set() # New bullets reset the parent hierarchy. self._actions = [Action(self, None, action, params, rank) for action, params in actions]