comparison pytouhou/game/enemymanager.py @ 40:ce662b372ee0

HANDLE RANDOM PLACEMENT (main flag 4) with results identical to 102h.exe \o/ \o/ \o/
author Thibaut Girka <thib@sitedethib.com>
date Mon, 15 Aug 2011 00:41:32 +0200
parents a10e3f44a883
children 1b0ca2fb89f9
comparison
equal deleted inserted replaced
39:493b503c81e0 40:ce662b372ee0
4 from struct import unpack, pack 4 from struct import unpack, pack
5 from pytouhou.utils.interpolator import Interpolator 5 from pytouhou.utils.interpolator import Interpolator
6 from pytouhou.game.eclrunner import ECLRunner 6 from pytouhou.game.eclrunner import ECLRunner
7 from pytouhou.game.sprite import Sprite 7 from pytouhou.game.sprite import Sprite
8 from math import cos, sin, atan2 8 from math import cos, sin, atan2
9
10
11 from pytouhou.utils.random import Random
12 random = Random(0x39f4)
9 13
10 14
11 class Enemy(object): 15 class Enemy(object):
12 def __init__(self, pos, life, _type, ecl_runner, anm_wrapper): 16 def __init__(self, pos, life, _type, ecl_runner, anm_wrapper):
13 self.anm_wrapper = anm_wrapper 17 self.anm_wrapper = anm_wrapper
206 def update(self, frame): 210 def update(self, frame):
207 if self.main and self.main[0][0] == frame: 211 if self.main and self.main[0][0] == frame:
208 for sub, instr_type, args in self.main.pop(0)[1]: 212 for sub, instr_type, args in self.main.pop(0)[1]:
209 if instr_type in (0, 2, 4, 6): # Normal/mirrored enemy 213 if instr_type in (0, 2, 4, 6): # Normal/mirrored enemy
210 x, y, z, life, unknown1, unknown2, unknown3 = args 214 x, y, z, life, unknown1, unknown2, unknown3 = args
215 if instr_type & 4:
216 if x < -990:
217 x = random.rand_double() * 368 #102h.exe@0x411820
218 if y < -990:
219 y = random.rand_double() * 416 #102h.exe@0x41184b
220 if z < -990:
221 y = random.rand_double() * 800 #102h.exe@0x411881
211 ecl_runner = ECLRunner(self.ecl, sub) 222 ecl_runner = ECLRunner(self.ecl, sub)
212 enemy = Enemy((x, y), life, instr_type, ecl_runner, self.anm_wrapper) 223 enemy = Enemy((x, y), life, instr_type, ecl_runner, self.anm_wrapper)
213 ecl_runner.implementation[1] = ('I', self.make_enemy_deleter(enemy)) 224 ecl_runner.implementation[1] = ('I', self.make_enemy_deleter(enemy))
214 225
215 self.enemies.append(enemy) 226 self.enemies.append(enemy)