comparison pytouhou/vm/__init__.py @ 599:d471b07ce4fd

Add a sample Python ECL.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 25 Oct 2014 18:52:21 +0200
parents e15672733c93
children d1f0bb0b7a17
comparison
equal deleted inserted replaced
598:a7286a0facf9 599:d471b07ce4fd
1 from .anmrunner import ANMRunner 1 from .anmrunner import ANMRunner
2 from .msgrunner import MSGRunner 2 from .msgrunner import MSGRunner
3 from .eclrunner import ECLMainRunner 3 from .eclrunner import ECLMainRunner
4
5
6 class PythonMainRunner(object):
7 def __init__(self, main, game):
8 self.main = main
9 self.game = game
10
11 def run_iter(self):
12 self.main(self.game)
13
14
15 class EnemyRunner(object):
16 def __init__(self, enemy, game, sub):
17 self.enemy = enemy
18 self.game = game
19 self.sub = sub
20
21 def run_iteration(self):
22 self.sub(self.enemy, self.game)
23
24
25 def spawn_enemy(game, sub, x=0., y=0., life=1, item=-1, score=0, mirrored=False, random=False):
26 instr_type = (2 if mirrored else 0) | (4 if random else 0)
27 enemy = game.new_enemy((x, y, 0.), life, instr_type, item, score)
28 enemy.process = EnemyRunner(enemy, game, sub)
29 enemy.process.run_iteration()