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:
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):
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
target - object with .x and .y fields for "aim" directions
vanished - set to true by a <vanish> 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
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]