changeset 472:8038f1957b71

Type bullettype, itemtype and lasertype a bit.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 16 Sep 2013 18:42:04 +0200
parents 06f0eeb519bb
children 1c891c71cf22
files pytouhou/game/bullet.pxd pytouhou/game/bullet.pyx pytouhou/game/bullettype.pxd pytouhou/game/bullettype.py pytouhou/game/item.pxd pytouhou/game/item.pyx pytouhou/game/itemtype.pxd pytouhou/game/laser.pxd pytouhou/game/laser.pyx pytouhou/game/lasertype.pxd pytouhou/game/player.pyx
diffstat 11 files changed, 33 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/game/bullet.pxd
+++ b/pytouhou/game/bullet.pxd
@@ -1,5 +1,6 @@
 from pytouhou.game.element cimport Element
 from pytouhou.game.game cimport Game
+from pytouhou.game.bullettype cimport BulletType
 from pytouhou.utils.interpolator cimport Interpolator
 
 
@@ -12,7 +13,8 @@ cdef class Bullet(Element):
     cdef public unsigned long flags, frame, sprite_idx_offset, damage
     cdef public double dx, dy, angle, speed
     cdef public bint player_bullet, was_visible, grazed
-    cdef public object target, _bullet_type
+    cdef public Element target
+    cdef public BulletType _bullet_type
     cdef public list attributes
 
     cdef double hitbox[2]
--- a/pytouhou/game/bullet.pyx
+++ b/pytouhou/game/bullet.pyx
@@ -19,7 +19,7 @@ from pytouhou.game.sprite cimport Sprite
 
 
 cdef class Bullet(Element):
-    def __init__(self, pos, bullet_type, unsigned long sprite_idx_offset,
+    def __init__(self, pos, BulletType bullet_type, unsigned long sprite_idx_offset,
                        double angle, double speed, attributes, unsigned long flags, target, Game game,
                        bint player_bullet=False, unsigned long damage=0, tuple hitbox=None):
         cdef double launch_mult
new file mode 100644
--- /dev/null
+++ b/pytouhou/game/bullettype.pxd
@@ -0,0 +1,7 @@
+cdef class BulletType:
+    cdef public long type_id
+    cdef long anim_index, hitbox_size, cancel_anim_index
+    cdef long launch_anim2_index, launch_anim4_index, launch_anim8_index
+    cdef tuple launch_anim_offsets
+    cdef float launch_anim_penalties[3]
+    cdef object anm
--- a/pytouhou/game/bullettype.py
+++ b/pytouhou/game/bullettype.py
@@ -13,6 +13,7 @@ class BulletType(object):
         self.launch_anim4_index = launch_anim4_index
         self.launch_anim8_index = launch_anim8_index
         self.hitbox_size = hitbox_size
-        self.launch_anim_penalties = launch_anim_penalties
+        assert 3 == len(launch_anim_penalties)
+        for i in xrange(3):
+            self.launch_anim_penalties[i] = launch_anim_penalties[i]
         self.launch_anim_offsets = launch_anim_offsets
-
--- a/pytouhou/game/item.pxd
+++ b/pytouhou/game/item.pxd
@@ -1,6 +1,7 @@
 from pytouhou.game.element cimport Element
 from pytouhou.game.game cimport Game
 from pytouhou.game.player cimport Player
+from pytouhou.game.itemtype cimport ItemType
 from pytouhou.utils.interpolator cimport Interpolator
 
 
@@ -11,7 +12,7 @@ cdef class Indicator(Element):
 
 
 cdef class Item(Element):
-    cdef public object _item_type
+    cdef public ItemType _item_type
 
     cdef unsigned long frame
     cdef long _type
--- a/pytouhou/game/item.pyx
+++ b/pytouhou/game/item.pyx
@@ -33,7 +33,7 @@ cdef class Indicator(Element):
 
 
 cdef class Item(Element):
-    def __init__(self, start_pos, long _type, item_type, Game game, double angle=pi/2, Player player=None, end_pos=None):
+    def __init__(self, start_pos, long _type, ItemType item_type, Game game, double angle=pi/2, Player player=None, end_pos=None):
         Element.__init__(self, start_pos)
 
         self._game = game
new file mode 100644
--- /dev/null
+++ b/pytouhou/game/itemtype.pxd
@@ -0,0 +1,5 @@
+from pytouhou.game.sprite cimport Sprite
+
+cdef class ItemType:
+    cdef Sprite sprite, indicator_sprite
+    cdef object anm
--- a/pytouhou/game/laser.pxd
+++ b/pytouhou/game/laser.pxd
@@ -1,6 +1,7 @@
 from pytouhou.game.element cimport Element
 from pytouhou.game.sprite cimport Sprite
 from pytouhou.game.game cimport Game
+from pytouhou.game.lasertype cimport LaserType
 
 cdef enum State:
     STARTING, STARTED, STOPPING
@@ -21,7 +22,7 @@ cdef class Laser(Element):
     cdef double base_pos[2], speed, start_offset, end_offset, max_length, width
     cdef State state
     cdef Game _game
-    cdef object _laser_type
+    cdef LaserType _laser_type
 
     cdef void set_anim(self, long sprite_idx_offset=*) except *
     cpdef set_base_pos(self, double x, double y)
@@ -37,7 +38,7 @@ cdef class PlayerLaser(Element):
     cdef double hitbox[2], angle, offset
     cdef unsigned long frame, duration, sprite_idx_offset, damage
     cdef Element origin
-    cdef object _laser_type
+    cdef LaserType _laser_type
 
     cdef void set_anim(self, long sprite_idx_offset=*) except *
     cdef void cancel(self) except *
--- a/pytouhou/game/laser.pyx
+++ b/pytouhou/game/laser.pyx
@@ -47,7 +47,7 @@ cdef class LaserLaunchAnim(Element):
 
 
 cdef class Laser(Element):
-    def __init__(self, tuple base_pos, laser_type,
+    def __init__(self, tuple base_pos, LaserType laser_type,
                  unsigned long sprite_idx_offset, double angle, double speed,
                  double start_offset, double end_offset, double max_length,
                  double width, unsigned long start_duration,
@@ -198,7 +198,7 @@ cdef class Laser(Element):
 
 
 cdef class PlayerLaser(Element):
-    def __init__(self, laser_type, unsigned long sprite_idx_offset,
+    def __init__(self, LaserType laser_type, unsigned long sprite_idx_offset,
                  tuple hitbox, unsigned long damage, double angle,
                  double offset, unsigned long duration, Element origin):
         Element.__init__(self)
new file mode 100644
--- /dev/null
+++ b/pytouhou/game/lasertype.pxd
@@ -0,0 +1,4 @@
+cdef class LaserType:
+    cdef long anim_index, launch_sprite_idx
+    cdef tuple launch_anim_offsets
+    cdef object anm
--- a/pytouhou/game/player.pyx
+++ b/pytouhou/game/player.pyx
@@ -16,9 +16,9 @@ from libc.math cimport M_PI as pi
 
 from pytouhou.game.sprite cimport Sprite
 from pytouhou.vm.anmrunner import ANMRunner
-from pytouhou.game.bullettype import BulletType
+from pytouhou.game.bullettype cimport BulletType
 from pytouhou.game.bullet cimport Bullet
-from pytouhou.game.lasertype import LaserType
+from pytouhou.game.lasertype cimport LaserType
 from pytouhou.game.laser cimport PlayerLaser