changeset 134:e9ac3640280b

Add support for enemy spawnling enemies.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 16 Sep 2011 11:21:33 -0700
parents 2cad2e84a49e
children c53d91300c1c
files pytouhou/game/enemy.py pytouhou/game/game.py pytouhou/vm/eclrunner.py
diffstat 3 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/game/enemy.py
+++ b/pytouhou/game/enemy.py
@@ -22,7 +22,7 @@ from math import cos, sin, atan2, pi
 
 
 class Enemy(object):
-    def __init__(self, pos, life, _type, anm_wrapper, game_state):
+    def __init__(self, pos, life, _type, anm_wrapper, game_state, pop_enemy):
         self._game_state = game_state
         self._anm_wrapper = anm_wrapper
         self._sprite = None
@@ -69,6 +69,8 @@ class Enemy(object):
         self.hitbox = (0, 0)
         self.screen_box = None
 
+        self.pop_enemy = pop_enemy
+
 
     def set_bullet_attributes(self, type_, anim, sprite_idx_offset,
                               bullets_per_shot, number_of_shots, speed, speed2,
--- a/pytouhou/game/game.py
+++ b/pytouhou/game/game.py
@@ -61,8 +61,8 @@ class Game(object):
         self.ecl_runner = ECLMainRunner(ecl, self.new_enemy, self.game_state)
 
 
-    def new_enemy(self, pos, life, instr_type):
-        enemy = Enemy(pos, life, instr_type, self.enm_anm_wrapper, self.game_state)
+    def new_enemy(self, pos, life, instr_type, pop_enemy):
+        enemy = Enemy(pos, life, instr_type, self.enm_anm_wrapper, self.game_state, pop_enemy)
         self.enemies.append(enemy)
         return enemy
 
--- a/pytouhou/vm/eclrunner.py
+++ b/pytouhou/vm/eclrunner.py
@@ -66,7 +66,7 @@ class ECLMainRunner(object):
     @instruction(2)
     @instruction(4)
     @instruction(6)
-    def pop_enemy(self, sub, instr_type, x, y, z, life, unknown1, unknown2, unknown3):
+    def pop_enemy(self, sub, instr_type, x, y, z, life, bonus_dropped, unknown2, unknown3):
         if self._game_state.boss:
             return
         if instr_type & 4:
@@ -76,7 +76,7 @@ class ECLMainRunner(object):
                 y = self._game_state.prng.rand_double() * 416
             if z < -990: #102h.exe@0x411881
                 y = self._game_state.prng.rand_double() * 800
-        enemy = self._new_enemy_func((x, y), life, instr_type)
+        enemy = self._new_enemy_func((x, y), life, instr_type, self.pop_enemy)
         process = ECLRunner(self._ecl, sub, enemy, self._game_state)
         self.processes.append(process)
         process.run_iteration()
@@ -640,7 +640,7 @@ class ECLRunner(object):
 
     @instruction(81)
     def set_bullet_launch_offset(self, x, y, z):
-        self._enemy.bullet_launch_offset = (x, y)
+        self._enemy.bullet_launch_offset = (self._getval(x), self._getval(y))
 
 
     @instruction(82)
@@ -654,6 +654,11 @@ class ECLRunner(object):
         print("%d - %s" % (number, name))
 
 
+    @instruction(95)
+    def pop_enemy(self, sub, x, y, z, life, bonus_dropped, unknown2):
+        self._enemy.pop_enemy(sub, 0, self._getval(x), self._getval(y), 0, life, bonus_dropped, unknown2, 0) # TODO: check about unknown values
+
+
     @instruction(97)
     def set_anim(self, sprite_index):
         self._enemy.set_anim(sprite_index)