projects
/
python-bulletml.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Construct Actions before passing to Bullet.
[python-bulletml.git]
/
bulletml
/
parser.py
diff --git
a/bulletml/parser.py
b/bulletml/parser.py
index
2075ac9
..
8bc23c0
100644
(file)
--- a/
bulletml/parser.py
+++ b/
bulletml/parser.py
@@
-367,9
+367,7
@@
class Repeat(object):
def __call__(self, owner, action, params, rank, created):
repeat = self.times(params, rank)
def __call__(self, owner, action, params, rank, created):
repeat = self.times(params, rank)
- actions, params = self.action(params, rank)
- child = action.__class__(
- owner, action, actions, params, rank, repeat)
+ child = action.Child(self.action, params, rank, repeat)
owner.replace(action, child)
child.step(owner, created)
return True
owner.replace(action, child)
child.step(owner, created)
return True
@@
-423,11
+421,18
@@
class If(object):
branch = self.else_
if branch:
branch = self.else_
if branch:
- actions, params = branch(params, rank)
- child = action.__class__(owner, action, actions, params, rank)
+ child = action.Child(branch, params, rank)
owner.replace(action, child)
child.step(owner, created)
return True
owner.replace(action, child)
child.step(owner, created)
return True
+
+ def __repr__(self):
+ if self.else_:
+ return "%s(%r, then=%r, else_=%r)" % (
+ type(self).__name__, self.cond, self.then, self.else_)
+ else:
+ return "%s(%r, then=%r)" % (
+ type(self).__name__, self.cond, self.then)
class Accel(object):
"""Accelerate over some time."""
class Accel(object):
"""Accelerate over some time."""
@@
-856,10
+861,13
@@
class FireDef(object):
if appearance is None:
appearance = owner.appearance
if appearance is None:
appearance = owner.appearance
+ Action = action.__class__
+ actions = [Action(None, action, params, rank)
+ for action, params in actions]
bullet = owner.__class__(
x=x, y=y, direction=direction, speed=speed,
target=owner.target, actions=actions, rank=rank,
bullet = owner.__class__(
x=x, y=y, direction=direction, speed=speed,
target=owner.target, actions=actions, rank=rank,
- appearance=appearance, tags=tags
, Action=action.__class__
)
+ appearance=appearance, tags=tags)
created.append(bullet)
def __repr__(self):
created.append(bullet)
def __repr__(self):