changeset 304:f3099ebf4f61

Update attribute names to reflect the actual interface.
author Thibaut Girka <thib@sitedethib.com>
date Tue, 13 Mar 2012 18:38:14 +0100
parents 647bde10353d
children 5492472963b0
files pytouhou/game/bullet.pyx pytouhou/game/effect.py pytouhou/game/enemy.py pytouhou/game/face.py pytouhou/game/game.py pytouhou/game/item.py pytouhou/game/laser.py pytouhou/game/orb.py pytouhou/game/player.py pytouhou/game/sprite.py pytouhou/game/text.py pytouhou/games/eosd.py pytouhou/ui/anmrenderer.py pytouhou/ui/gamerenderer.pyx pytouhou/ui/gamerunner.py pytouhou/ui/renderer.pyx pytouhou/ui/sprite.pyx pytouhou/vm/anmrunner.py pytouhou/vm/eclrunner.py
diffstat 19 files changed, 247 insertions(+), 240 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/game/bullet.pyx
+++ b/pytouhou/game/bullet.pyx
@@ -25,7 +25,8 @@ cdef class Bullet(object):
     cdef public unsigned int _state, flags, frame, sprite_idx_offset
     cdef public double dx, dy, angle, speed #TODO
     cdef public object player_bullet, target
-    cdef public object _game, _sprite, _anmrunner, _removed, _bullet_type, _was_visible
+    cdef public object _game, _bullet_type
+    cdef public object sprite, anmrunner, removed, was_visible
     cdef public object attributes, damage, hitbox_half_size, speed_interpolator, grazed
     cdef public object x, y #TODO
 
@@ -33,12 +34,12 @@ cdef class Bullet(object):
                        angle, speed, attributes, flags, target, game,
                        player_bullet=False, damage=0, hitbox=None):
         self._game = game
-        self._sprite = None
-        self._anmrunner = None
-        self._removed = False
         self._bullet_type = bullet_type
-        self._was_visible = True
         self._state = LAUNCHING
+        self.sprite = None
+        self.anmrunner = None
+        self.removed = False
+        self.was_visible = True
 
         if hitbox:
             self.hitbox_half_size = (hitbox[0] / 2., hitbox[1] / 2.)
@@ -76,22 +77,22 @@ cdef class Bullet(object):
                 index = bullet_type.launch_anim8_index
                 launch_mult = bullet_type.launch_anim_penalties[2]
             self.dx, self.dy = self.dx * launch_mult, self.dy * launch_mult
-            self._sprite = Sprite()
-            self._anmrunner = ANMRunner(bullet_type.anm_wrapper,
-                                        index, self._sprite,
+            self.sprite = Sprite()
+            self.anmrunner = ANMRunner(bullet_type.anm_wrapper,
+                                        index, self.sprite,
                                         bullet_type.launch_anim_offsets[sprite_idx_offset])
-            self._anmrunner.run_frame()
+            self.anmrunner.run_frame()
         else:
             self.launch()
 
         if self.player_bullet:
-            self._sprite.angle = angle - pi
+            self.sprite.angle = angle - pi
         else:
-            self._sprite.angle = angle
+            self.sprite.angle = angle
 
 
     cpdef is_visible(Bullet self, screen_width, screen_height):
-        tx, ty, tw, th = self._sprite.texcoords
+        tx, ty, tw, th = self.sprite.texcoords
         x, y = self.x, self.y
 
         max_x = tw / 2.
@@ -110,14 +111,14 @@ cdef class Bullet(object):
             self.sprite_idx_offset = sprite_idx_offset
 
         bt = self._bullet_type
-        self._sprite = Sprite()
+        self.sprite = Sprite()
         if self.player_bullet:
-            self._sprite.angle = self.angle - pi
+            self.sprite.angle = self.angle - pi
         else:
-            self._sprite.angle = self.angle
-        self._anmrunner = ANMRunner(bt.anm_wrapper, bt.anim_index,
-                                    self._sprite, self.sprite_idx_offset)
-        self._anmrunner.run_frame()
+            self.sprite.angle = self.angle
+        self.anmrunner = ANMRunner(bt.anm_wrapper, bt.anim_index,
+                                   self.sprite, self.sprite_idx_offset)
+        self.anmrunner.run_frame()
 
 
     def launch(Bullet self):
@@ -137,14 +138,14 @@ cdef class Bullet(object):
     def cancel(Bullet self):
         # Cancel animation
         bt = self._bullet_type
-        self._sprite = Sprite()
+        self.sprite = Sprite()
         if self.player_bullet:
-            self._sprite.angle = self.angle - pi
+            self.sprite.angle = self.angle - pi
         else:
-            self._sprite.angle = self.angle
-        self._anmrunner = ANMRunner(bt.anm_wrapper, bt.cancel_anim_index,
-                                    self._sprite, bt.launch_anim_offsets[self.sprite_idx_offset])
-        self._anmrunner.run_frame()
+            self.sprite.angle = self.angle
+        self.anmrunner = ANMRunner(bt.anm_wrapper, bt.cancel_anim_index,
+                                   self.sprite, bt.launch_anim_offsets[self.sprite_idx_offset])
+        self.anmrunner.run_frame()
         self.dx, self.dy = self.dx / 2., self.dy / 2.
 
         # Change update method
@@ -159,14 +160,14 @@ cdef class Bullet(object):
 
 
     def update(Bullet self):
-        if self._anmrunner is not None and not self._anmrunner.run_frame():
+        if self.anmrunner is not None and not self.anmrunner.run_frame():
             if self._state == LAUNCHING:
                 #TODO: check if it doesn't skip a frame
                 self.launch()
             elif self._state == CANCELLED:
-                self._removed = True
+                self.removed = True
             else:
-                self._anmrunner = None
+                self.anmrunner = None
 
         if self._state == LAUNCHING:
             pass
@@ -184,9 +185,9 @@ cdef class Bullet(object):
             self.dx += cos(angle) * length
             self.dy += sin(angle) * length
             self.speed = (self.dx ** 2 + self.dy ** 2) ** 0.5
-            self.angle = self._sprite.angle = atan2(self.dy, self.dx)
-            if self._sprite.automatic_orientation:
-                self._sprite._changed = True
+            self.angle = self.sprite.angle = atan2(self.dy, self.dx)
+            if self.sprite.automatic_orientation:
+                self.sprite.changed = True
             if self.frame == self.attributes[0]: #TODO: include last frame, or not?
                 self.flags &= ~16
         elif self.flags & 32:
@@ -197,9 +198,9 @@ cdef class Bullet(object):
             self.angle += angular_speed
             self.dx = cos(self.angle) * self.speed
             self.dy = sin(self.angle) * self.speed
-            self._sprite.angle = self.angle
-            if self._sprite.automatic_orientation:
-                self._sprite._changed = True
+            self.sprite.angle = self.angle
+            if self.sprite.automatic_orientation:
+                self.sprite.changed = True
             if self.frame == self.attributes[0]:
                 self.flags &= ~32
         elif self.flags & 448:
@@ -222,9 +223,9 @@ cdef class Bullet(object):
 
                     self.dx = cos(self.angle) * self.speed
                     self.dy = sin(self.angle) * self.speed
-                    self._sprite.angle = self.angle
-                    if self._sprite.automatic_orientation:
-                        self._sprite._changed = True
+                    self.sprite.angle = self.angle
+                    if self.sprite.automatic_orientation:
+                        self.sprite.changed = True
 
                 if count >= 0:
                     self.speed_interpolator = Interpolator((self.speed,), self.frame,
@@ -249,22 +250,22 @@ cdef class Bullet(object):
 
         # Filter out-of-screen bullets and handle special flags
         if self.flags & 448:
-            self._was_visible = False
+            self.was_visible = False
         elif self.is_visible(self._game.width, self._game.height):
-            self._was_visible = True
-        elif self._was_visible:
-            self._removed = True
+            self.was_visible = True
+        elif self.was_visible:
+            self.removed = True
             if self.flags & (1024 | 2048) and self.attributes[0] > 0:
                 # Bounce!
                 if self.x < 0 or self.x > self._game.width:
                     self.angle = pi - self.angle
-                    self._removed = False
+                    self.removed = False
                 if self.y < 0 or ((self.flags & 1024) and self.y > self._game.height):
                     self.angle = -self.angle
-                    self._removed = False
-                self._sprite.angle = self.angle
-                if self._sprite.automatic_orientation:
-                    self._sprite._changed = True
+                    self.removed = False
+                self.sprite.angle = self.angle
+                if self.sprite.automatic_orientation:
+                    self.sprite.changed = True
                 self.dx = cos(self.angle) * self.speed
                 self.dy = sin(self.angle) * self.speed
                 self.attributes[0] -= 1
--- a/pytouhou/game/effect.py
+++ b/pytouhou/game/effect.py
@@ -22,35 +22,37 @@ from math import pi
 
 class Effect(object):
     def __init__(self, pos, index, anm_wrapper):
-        self._sprite = Sprite()
-        self._anmrunner = ANMRunner(anm_wrapper, index, self._sprite)
-        self._anmrunner.run_frame()
-        self._removed = False
+        self.sprite = Sprite()
+        self.anmrunner = ANMRunner(anm_wrapper, index, self.sprite)
+        self.anmrunner.run_frame()
+        self.removed = False
 
         self.x, self.y = pos
 
 
     def update(self):
-        if self._anmrunner and not self._anmrunner.run_frame():
-            self._anmrunner = None
+        if self.anmrunner and not self.anmrunner.run_frame():
+            self.anmrunner = None
 
-        if self._sprite:
-            if self._sprite._removed:
-                self._sprite = None
+        if self.sprite:
+            if self.sprite.removed:
+                self.sprite = None
+
 
 
 class Particle(object):
     def __init__(self, start_pos, index, anm_wrapper, size, amp, game):
-        self._sprite = Sprite()
-        self._sprite.anm, self._sprite.texcoords = anm_wrapper.get_sprite(index)
         self._game = game
-        self._removed = False
+
+        self.sprite = Sprite()
+        self.sprite.anm, self.sprite.texcoords = anm_wrapper.get_sprite(index)
+        self.removed = False
 
         self.x, self.y = start_pos
         self.frame = 0
-        self._sprite.alpha = 128
-        self._sprite.blendfunc = 1
-        self._sprite.rescale = (size, size)
+        self.sprite.alpha = 128
+        self.sprite.blendfunc = 1
+        self.sprite.rescale = (size, size)
 
         self.pos_interpolator = None
         self.scale_interpolator = None
@@ -65,9 +67,9 @@ class Particle(object):
 
         self.pos_interpolator = Interpolator((self.x, self.y), 0,
                                              end_pos, 24, formula=(lambda x: 2. * x - x ** 2))
-        self.scale_interpolator = Interpolator(self._sprite.rescale, 0,
+        self.scale_interpolator = Interpolator(self.sprite.rescale, 0,
                                                (0., 0.), 24)
-        self.rotations_interpolator = Interpolator(self._sprite.rotations_3d, 0,
+        self.rotations_interpolator = Interpolator(self.sprite.rotations_3d, 0,
                                                    (0., 0., 2*pi), 24)
 
 
@@ -80,14 +82,15 @@ class Particle(object):
             self.x, self.y = self.pos_interpolator.values
 
             self.scale_interpolator.update(self.frame)
-            self._sprite.rescale = self.scale_interpolator.values
+            self.sprite.rescale = self.scale_interpolator.values
 
             self.rotations_interpolator.update(self.frame)
-            self._sprite.rotations_3d = self.rotations_interpolator.values
+            self.sprite.rotations_3d = self.rotations_interpolator.values
 
-            self._sprite._changed = True
+            self.sprite.changed = True
 
         if self.frame == 24:
-            self._removed = True
+            self.removed = True
 
         self.frame += 1
+
--- a/pytouhou/game/enemy.py
+++ b/pytouhou/game/enemy.py
@@ -26,14 +26,15 @@ class Enemy(object):
     def __init__(self, pos, life, _type, bonus_dropped, die_score, anm_wrapper, game):
         self._game = game
         self._anm_wrapper = anm_wrapper
-        self._sprite = None
-        self._anmrunner = None
-        self._removed = False
-        self._visible = True
         self._type = _type
-        self._bonus_dropped = bonus_dropped
-        self._die_score = die_score #TODO: use it
-        self._was_visible = False
+
+        self.sprite = None
+        self.anmrunner = None
+        self.removed = False
+        self.visible = True
+        self.was_visible = False
+        self.bonus_dropped = bonus_dropped
+        self.die_score = die_score #TODO: use it
 
         self.frame = 0
 
@@ -192,9 +193,9 @@ class Enemy(object):
 
 
     def set_anim(self, index):
-        self._sprite = Sprite()
-        self._anmrunner = ANMRunner(self._anm_wrapper, index, self._sprite)
-        self._anmrunner.run_frame()
+        self.sprite = Sprite()
+        self.anmrunner = ANMRunner(self._anm_wrapper, index, self.sprite)
+        self.anmrunner.run_frame()
 
 
     def die_anim(self):
@@ -244,9 +245,9 @@ class Enemy(object):
 
 
     def is_visible(self, screen_width, screen_height):
-        if self._sprite:
-            tx, ty, tw, th = self._sprite.texcoords
-            if self._sprite.corner_relative_placement:
+        if self.sprite:
+            tx, ty, tw, th = self.sprite.texcoords
+            if self.sprite.corner_relative_placement:
                 raise Exception #TODO
         else:
             tx, ty, tw, th = 0., 0., 0., 0.
@@ -381,15 +382,15 @@ class Enemy(object):
         self.x, self.y = x, y
 
         #TODO
-        if self._anmrunner and not self._anmrunner.run_frame():
-            self._anmrunner = None
+        if self.anmrunner and not self.anmrunner.run_frame():
+            self.anmrunner = None
 
-        if self._sprite and self._visible:
-            if self._sprite._removed:
-                self._sprite = None
+        if self.sprite and self.visible:
+            if self.sprite.removed:
+                self.sprite = None
             else:
-                self._sprite.update_orientation(self.angle,
-                                                self.automatic_orientation)
+                self.sprite.update_orientation(self.angle,
+                                               self.automatic_orientation)
 
 
         if self.bullet_launch_interval != 0:
--- a/pytouhou/game/face.py
+++ b/pytouhou/game/face.py
@@ -18,12 +18,12 @@ from pytouhou.vm.anmrunner import ANMRun
 
 
 class Face(object):
-    __slots__ = ('_anm_wrapper', '_sprite', '_anmrunner', 'side', 'x', 'y')
+    __slots__ = ('_anm_wrapper', 'sprite', 'anmrunner', 'side', 'x', 'y')
 
     def __init__(self, anm_wrapper, effect, side):
         self._anm_wrapper = anm_wrapper
-        self._sprite = Sprite()
-        self._anmrunner = ANMRunner(anm_wrapper, side * 2, self._sprite)
+        self.sprite = Sprite()
+        self.anmrunner = ANMRunner(anm_wrapper, side * 2, self.sprite)
         self.side = side
         self.load(0)
         self.animate(effect)
@@ -31,17 +31,18 @@ class Face(object):
         #FIXME: the same as game.effect.
         self.x = -32
         self.y = -16
-        self._sprite.allow_dest_offset = True
+        self.sprite.allow_dest_offset = True
 
 
     def animate(self, effect):
-        self._anmrunner.interrupt(effect)
+        self.anmrunner.interrupt(effect)
 
 
     def load(self, index):
-        self._sprite.anm, self._sprite.texcoords = self._anm_wrapper.get_sprite(self.side * 8 + index)
-        self._anmrunner.run_frame()
+        self.sprite.anm, self.sprite.texcoords = self._anm_wrapper.get_sprite(self.side * 8 + index)
+        self.anmrunner.run_frame()
 
 
     def update(self):
-        self._anmrunner.run_frame()
+        self.anmrunner.run_frame()
+
--- a/pytouhou/game/game.py
+++ b/pytouhou/game/game.py
@@ -106,7 +106,7 @@ class Game(object):
 
     def enable_effect(self):
         self.effect = Effect((-32., -16.), 0, self.effect_anm_wrapper) #TODO: find why this offset is necessary.
-        self.effect._sprite.allow_dest_offset = True #TODO: should be the role of anm’s 25th instruction. Investigate!
+        self.effect.sprite.allow_dest_offset = True #TODO: should be the role of anm’s 25th instruction. Investigate!
 
 
     def disable_effect(self):
@@ -168,11 +168,11 @@ class Game(object):
             self.modify_difficulty(+100)
 
         # 2. Filter out destroyed enemies
-        self.enemies = [enemy for enemy in self.enemies if not enemy._removed]
-        self.effects = [effect for effect in self.effects if not effect._removed]
-        self.bullets = [bullet for bullet in self.bullets if not bullet._removed]
-        self.cancelled_bullets = [bullet for bullet in self.cancelled_bullets if not bullet._removed]
-        self.items = [item for item in self.items if not item._removed]
+        self.enemies = [enemy for enemy in self.enemies if not enemy.removed]
+        self.effects = [effect for effect in self.effects if not effect.removed]
+        self.bullets = [bullet for bullet in self.bullets if not bullet.removed]
+        self.cancelled_bullets = [bullet for bullet in self.cancelled_bullets if not bullet.removed]
+        self.items = [item for item in self.items if not item.removed]
 
 
         # 3. Let's play!
@@ -327,27 +327,27 @@ class Game(object):
         # Filter out non-visible enemies
         for enemy in self.enemies:
             if enemy.is_visible(self.width, self.height):
-                enemy._was_visible = True
-            elif enemy._was_visible:
+                enemy.was_visible = True
+            elif enemy.was_visible:
                 # Filter out-of-screen enemy
-                enemy._removed = True
+                enemy.removed = True
 
-        self.enemies = [enemy for enemy in self.enemies if not enemy._removed]
+        self.enemies = [enemy for enemy in self.enemies if not enemy.removed]
 
         # Filter out-of-scren bullets
         self.bullets = [bullet for bullet in self.bullets
-                            if not bullet._removed]
+                            if not bullet.removed]
         self.players_bullets = [bullet for bullet in self.players_bullets
-                            if not bullet._removed]
+                            if not bullet.removed]
         for i, laser in enumerate(self.players_lasers):
-            if laser and laser._removed:
+            if laser and laser.removed:
                 self.players_lasers[i] = None
         self.cancelled_bullets = [bullet for bullet in self.cancelled_bullets
-                            if not bullet._removed]
-        self.effects = [effect for effect in self.effects if not effect._removed]
+                            if not bullet.removed]
+        self.effects = [effect for effect in self.effects if not effect.removed]
 
         # Filter “timed-out” lasers
-        self.lasers = [laser for laser in self.lasers if not laser._removed]
+        self.lasers = [laser for laser in self.lasers if not laser.removed]
 
         # Filter out-of-scren items
         items = []
@@ -359,6 +359,6 @@ class Game(object):
         self.items = items
 
         # Disable boss mode if it is dead/it has timeout
-        if self.boss and self.boss._enemy._removed:
+        if self.boss and self.boss._enemy.removed:
             self.boss = None
 
--- a/pytouhou/game/item.py
+++ b/pytouhou/game/item.py
@@ -21,8 +21,8 @@ from pytouhou.utils.interpolator import 
 class Item(object):
     def __init__(self, start_pos, _type, item_type, game, angle=pi/2, player=None, end_pos=None):
         self._game = game
-        self._sprite = item_type.sprite
-        self._removed = False
+        self.sprite = item_type.sprite
+        self.removed = False
         self._type = _type
         self._item_type = item_type
 
@@ -45,7 +45,7 @@ class Item(object):
                 self.speed_interpolator = Interpolator((-2.,), 0,
                                                        (0.,), 60)
 
-        self._sprite.angle = angle
+        self.sprite.angle = angle
 
 
     def autocollect(self, player):
@@ -115,7 +115,7 @@ class Item(object):
             #TODO: display the score.
             player_state.score += score
 
-        self._removed = True
+        self.removed = True
 
 
     def update(self):
--- a/pytouhou/game/laser.py
+++ b/pytouhou/game/laser.py
@@ -24,10 +24,10 @@ STARTING, STARTED, STOPPING = range(3)
 class LaserLaunchAnim(object):
     def __init__(self, laser, anm_wrapper, index):
         self._laser = laser
-        self._sprite = Sprite()
-        self._sprite.anm, self._sprite.texcoords = anm_wrapper.get_sprite(index)
-        self._sprite.blendfunc = 1
-        self._removed = False
+        self.sprite = Sprite()
+        self.sprite.anm, self.sprite.texcoords = anm_wrapper.get_sprite(index)
+        self.sprite.blendfunc = 1
+        self.removed = False
         self.x, self.y = 0, 0
 
 
@@ -41,11 +41,11 @@ class LaserLaunchAnim(object):
         self.y = laser.base_pos[1] + offset * dy
 
         scale = laser.width / 10. - (offset - laser.start_offset)
-        self._sprite.rescale = (scale, scale)
-        self._sprite._changed = True
+        self.sprite.rescale = (scale, scale)
+        self.sprite.changed = True
 
-        if laser._removed or scale <= 0.:
-            self._removed = True
+        if laser.removed or scale <= 0.:
+            self.removed = True
 
 
 
@@ -60,11 +60,11 @@ class Laser(object):
                                       laser_type.launch_anim_offsets[sprite_idx_offset]
                                       + laser_type.launch_sprite_idx)
         self._game.effects.append(launch_anim)
-        self._sprite = None
-        self._anmrunner = None
-        self._removed = False
         self._laser_type = laser_type
         self.state = STARTING
+        self.sprite = None
+        self.anmrunner = None
+        self.removed = False
 
         #TODO: hitbox
 
@@ -93,11 +93,11 @@ class Laser(object):
             self.sprite_idx_offset = sprite_idx_offset
 
         lt = self._laser_type
-        self._sprite = Sprite()
-        self._sprite.angle = self.angle
-        self._anmrunner = ANMRunner(lt.anm_wrapper, lt.anim_index,
-                                    self._sprite, self.sprite_idx_offset)
-        self._anmrunner.run_frame()
+        self.sprite = Sprite()
+        self.sprite.angle = self.angle
+        self.anmrunner = ANMRunner(lt.anm_wrapper, lt.anim_index,
+                                   self.sprite, self.sprite_idx_offset)
+        self.anmrunner.run_frame()
 
 
     def _check_collision(self, point, border_size):
@@ -158,8 +158,8 @@ class Laser(object):
 
 
     def update(self):
-        if self._anmrunner is not None and not self._anmrunner.run_frame():
-            self._anmrunner = None
+        if self.anmrunner is not None and not self.anmrunner.run_frame():
+            self.anmrunner = None
 
         self.end_offset += self.speed
 
@@ -178,17 +178,17 @@ class Laser(object):
         if self.state == STOPPING:
             if self.frame == self.stop_duration:
                 width = 0.
-                self._removed = True
+                self.removed = True
             else:
                 width = self.width * (1. - float(self.frame) / self.stop_duration) #TODO
 
         offset = self.end_offset - length / 2.
         self.x, self.y = self.base_pos[0] + offset * cos(self.angle), self.base_pos[1] + offset * sin(self.angle)
-        self._sprite.width_override = width or 0.01 #TODO
-        self._sprite.height_override = length or 0.01 #TODO
+        self.sprite.width_override = width or 0.01 #TODO
+        self.sprite.height_override = length or 0.01 #TODO
 
-        self._sprite.update_orientation(pi/2. - self.angle, True)
-        self._sprite._changed = True #TODO
+        self.sprite.update_orientation(pi/2. - self.angle, True)
+        self.sprite.changed = True #TODO
 
         self.frame += 1
 
@@ -196,9 +196,9 @@ class Laser(object):
 class PlayerLaser(object):
     def __init__(self, laser_type, sprite_idx_offset, hitbox, damage,
                  angle, offset, duration, origin):
-        self._sprite = None
-        self._anmrunner = None
-        self._removed = False
+        self.sprite = None
+        self.anmrunner = None
+        self.removed = False
         self._laser_type = laser_type
         self.origin = origin
 
@@ -230,28 +230,28 @@ class PlayerLaser(object):
             self.sprite_idx_offset = sprite_idx_offset
 
         lt = self._laser_type
-        self._sprite = Sprite()
-        self._anmrunner = ANMRunner(lt.anm_wrapper, lt.anim_index,
-                                    self._sprite, self.sprite_idx_offset)
-        #self._sprite.blendfunc = 1 #XXX
-        self._anmrunner.run_frame()
+        self.sprite = Sprite()
+        self.anmrunner = ANMRunner(lt.anm_wrapper, lt.anim_index,
+                                   self.sprite, self.sprite_idx_offset)
+        #self.sprite.blendfunc = 1 #XXX
+        self.anmrunner.run_frame()
 
 
     def cancel(self):
-        self._anmrunner.interrupt(1)
+        self.anmrunner.interrupt(1)
 
 
     def update(self):
-        if self._anmrunner is not None and not self._anmrunner.run_frame():
-            self._anmrunner = None
-            self._removed = True
+        if self.anmrunner is not None and not self.anmrunner.run_frame():
+            self.anmrunner = None
+            self.removed = True
 
         length = self.origin.y
         if self.frame == self.duration:
             self.cancel()
 
-        self._sprite.height_override = length or 0.01 #TODO
-        self._sprite._changed = True #TODO
+        self.sprite.height_override = length or 0.01 #TODO
+        self.sprite.changed = True #TODO
 
         self.frame += 1
 
--- a/pytouhou/game/orb.py
+++ b/pytouhou/game/orb.py
@@ -18,13 +18,13 @@ from pytouhou.vm.anmrunner import ANMRun
 
 
 class Orb(object):
-    __slots__ = ('_sprite', '_anmrunner', 'offset_x', 'offset_y', 'player_state',
+    __slots__ = ('sprite', 'anmrunner', 'offset_x', 'offset_y', 'player_state',
                  'fire')
 
     def __init__(self, anm_wrapper, index, player_state, fire_func):
-        self._sprite = Sprite()
-        self._anmrunner = ANMRunner(anm_wrapper, index, self._sprite)
-        self._anmrunner.run_frame()
+        self.sprite = Sprite()
+        self.anmrunner = ANMRunner(anm_wrapper, index, self.sprite)
+        self.anmrunner.run_frame()
 
         self.offset_x = 0
         self.offset_y = 0
@@ -44,4 +44,5 @@ class Orb(object):
 
 
     def update(self):
-        self._anmrunner.run_frame()
+        self.anmrunner.run_frame()
+
--- a/pytouhou/game/player.py
+++ b/pytouhou/game/player.py
@@ -48,9 +48,9 @@ class PlayerState(object):
 
 class Player(object):
     def __init__(self, state, game, anm_wrapper):
-        self._sprite = None
-        self._anmrunner = None
         self._game = game
+        self.sprite = None
+        self.anmrunner = None
         self.anm_wrapper = anm_wrapper
 
         self.speeds = (self.sht.horizontal_vertical_speed,
@@ -86,9 +86,9 @@ class Player(object):
 
 
     def set_anim(self, index):
-        self._sprite = Sprite()
-        self._anmrunner = ANMRunner(self.anm_wrapper, index, self._sprite)
-        self._anmrunner.run_frame()
+        self.sprite = Sprite()
+        self.anmrunner = ANMRunner(self.anm_wrapper, index, self.sprite)
+        self.anmrunner.run_frame()
 
 
     def collide(self):
@@ -193,11 +193,11 @@ class Player(object):
 
                 m = self.state.invulnerable_time % 8
                 if m == 0:
-                    self._sprite.color = (255, 255, 255)
-                    self._sprite._changed = True
+                    self.sprite.color = (255, 255, 255)
+                    self.sprite.changed = True
                 elif m == 2:
-                    self._sprite.color = (64, 64, 64)
-                    self._sprite._changed = True
+                    self.sprite.color = (64, 64, 64)
+                    self.sprite.changed = True
 
             if keystate & 1 and self.fire_time == 0:
                 self.fire_time = 30
@@ -224,31 +224,31 @@ class Player(object):
                                                    self._game.prng.rand_double() * 192 - 64))
 
             elif time == 7:
-                self._sprite.mirrored = False
-                self._sprite.blendfunc = 0
-                self._sprite.rescale = 0.75, 1.5
-                self._sprite.fade(26, 96, lambda x: x)
-                self._sprite.scale_in(26, 0.00, 2.5, lambda x: x)
+                self.sprite.mirrored = False
+                self.sprite.blendfunc = 0
+                self.sprite.rescale = 0.75, 1.5
+                self.sprite.fade(26, 96, lambda x: x)
+                self.sprite.scale_in(26, 0.00, 2.5, lambda x: x)
 
             elif time == 32:
                 self.state.x = float(self._game.width) / 2. #TODO
                 self.state.y = float(self._game.width) #TODO
                 self.direction = None
 
-                self._sprite = Sprite()
-                self._anmrunner = ANMRunner(self.anm_wrapper, 0, self._sprite)
-                self._sprite.alpha = 128
-                self._sprite.rescale = 0.0, 2.5
-                self._sprite.fade(30, 255, lambda x: x)
-                self._sprite.blendfunc = 1
-                self._sprite.scale_in(30, 1., 1., lambda x: x)
-                self._anmrunner.run_frame()
+                self.sprite = Sprite()
+                self.anmrunner = ANMRunner(self.anm_wrapper, 0, self.sprite)
+                self.sprite.alpha = 128
+                self.sprite.rescale = 0.0, 2.5
+                self.sprite.fade(30, 255, lambda x: x)
+                self.sprite.blendfunc = 1
+                self.sprite.scale_in(30, 1., 1., lambda x: x)
+                self.anmrunner.run_frame()
 
             elif time == 61: # respawned
                 self.state.touchable = True
                 self.state.invulnerable_time = 240
-                self._sprite.blendfunc = 0
-                self._sprite._changed = True
+                self.sprite.blendfunc = 0
+                self.sprite.changed = True
 
             if time > 30:
                 for bullet in self._game.bullets:
@@ -259,5 +259,5 @@ class Player(object):
             if time > 90: # start the bullet hell again
                 self.death_time = 0
 
-        self._anmrunner.run_frame()
+        self.anmrunner.run_frame()
 
--- a/pytouhou/game/sprite.py
+++ b/pytouhou/game/sprite.py
@@ -17,7 +17,7 @@ from pytouhou.utils.interpolator import 
 
 
 class Sprite(object):
-    __slots__ = ('anm', '_removed', '_changed', 'width_override', 'height_override',
+    __slots__ = ('anm', 'removed', 'changed', 'width_override', 'height_override',
                  'angle', 'force_rotation', 'scale_interpolator', 'fade_interpolator',
                  'offset_interpolator', 'automatic_orientation', 'blendfunc',
                  'texcoords', 'dest_offset', 'allow_dest_offset', 'texoffsets',
@@ -26,8 +26,8 @@ class Sprite(object):
                  'color', 'alpha', 'visible', '_rendering_data')
     def __init__(self, width_override=0, height_override=0):
         self.anm = None
-        self._removed = False
-        self._changed = True
+        self.removed = False
+        self.changed = True
         self.visible = True
 
         self.width_override = width_override
@@ -82,5 +82,5 @@ class Sprite(object):
         if (self.angle != angle_base or self.force_rotation != force_rotation):
             self.angle = angle_base
             self.force_rotation = force_rotation
-            self._changed = True
+            self.changed = True
 
--- a/pytouhou/game/text.py
+++ b/pytouhou/game/text.py
@@ -20,19 +20,19 @@ from pytouhou.vm.anmrunner import ANMRun
 
 class Glyph(object):
     def __init__(self, sprite, pos):
-        self._sprite = sprite
-        self._removed = False
+        self.sprite = sprite
+        self.removed = False
 
         self.x, self.y = pos
 
 
 class Text(object):
     def __init__(self, pos, text, front_wrapper, ascii_wrapper):
-        self._sprite = Sprite()
-        self._anmrunner = ANMRunner(front_wrapper, 22, self._sprite)
-        self._anmrunner.run_frame()
-        self._removed = False
-        self._changed = True
+        self.sprite = Sprite()
+        self.anmrunner = ANMRunner(front_wrapper, 22, self.sprite)
+        self.anmrunner.run_frame()
+        self.removed = False
+        self.changed = True
 
         self.text = ''
         self.glyphes = []
@@ -63,16 +63,16 @@ class Text(object):
             self.glyphes[:] = self.glyphes[:len(text)]
 
         for glyph, character in zip(self.glyphes, text):
-            glyph._sprite.anm, glyph._sprite.texcoords = self.ascii_wrapper.get_sprite(ord(character) - 21)
-            glyph._sprite._changed = True
+            glyph.sprite.anm, glyph.sprite.texcoords = self.ascii_wrapper.get_sprite(ord(character) - 21)
+            glyph.sprite.changed = True
 
         self.text = text
-        self._changed = True
+        self.changed = True
 
 
     def update(self):
-        if self._changed:
-            if self._anmrunner and not self._anmrunner.run_frame():
-                self._anmrunner = None
-            self._changed = False
+        if self.changed:
+            if self.anmrunner and not self.anmrunner.run_frame():
+                self.anmrunner = None
+            self.changed = False
 
--- a/pytouhou/games/eosd.py
+++ b/pytouhou/games/eosd.py
@@ -109,7 +109,7 @@ class EoSDInterface(Game):
                       [Effect((0, 0), 5, front)] +
                       [Effect((0, 0), i, front) for i in range(5) + range(9, 16)])
         for item in self.items:
-            item._sprite.allow_dest_offset = True #XXX
+            item.sprite.allow_dest_offset = True #XXX
 
         self.labels = {
             'highscore': Text((500, 58), '0', front, ascii_wrapper),
--- a/pytouhou/ui/anmrenderer.py
+++ b/pytouhou/ui/anmrenderer.py
@@ -122,19 +122,19 @@ class ANMRenderer(pyglet.window.Window, 
             if modifiers & pyglet.window.key.MOD_SHIFT:
                 interrupt += 12
             if not self.sprites:
-                self._anmrunner.interrupt(interrupt)
+                self.anmrunner.interrupt(interrupt)
 
 
     def load(self, index=None):
         if index is None:
             index = self.num
-        self._sprite = Sprite()
+        self.sprite = Sprite()
         if self.sprites:
-            self._sprite.anm, self._sprite.texcoords = self._anm_wrapper.get_sprite(index)
+            self.sprite.anm, self.sprite.texcoords = self._anm_wrapper.get_sprite(index)
             print('Loaded sprite %d' % index)
         else:
-            self._anmrunner = ANMRunner(self._anm_wrapper, index, self._sprite)
-            print('Loading anim %d, handled events: %r' % (index, self._anmrunner.script.interrupts.keys()))
+            self.anmrunner = ANMRunner(self._anm_wrapper, index, self.sprite)
+            print('Loading anim %d, handled events: %r' % (index, self.anmrunner.script.interrupts.keys()))
         self.num = index
 
 
@@ -169,13 +169,13 @@ class ANMRenderer(pyglet.window.Window, 
 
     def update(self):
         if not self.sprites:
-             self._anmrunner.run_frame()
+             self.anmrunner.run_frame()
 
         if self.force_allow_dest_offset:
-            self._sprite.allow_dest_offset = True
+            self.sprite.allow_dest_offset = True
 
         glClearColor(*self.clear_color)
         glClear(GL_COLOR_BUFFER_BIT)
-        if not self._sprite._removed:
+        if not self.sprite.removed:
             self.render_elements([self])
 
--- a/pytouhou/ui/gamerenderer.pyx
+++ b/pytouhou/ui/gamerenderer.pyx
@@ -80,8 +80,8 @@ cdef class GameRenderer(Renderer):
             self.setup_camera(0, 0, 1)
 
             glDisable(GL_FOG)
-            self.render_elements(chain(*(enemy.objects() for enemy in game.enemies if enemy._visible)))
-            self.render_elements(enemy for enemy in game.enemies if enemy._visible)
+            self.render_elements(chain(*(enemy.objects() for enemy in game.enemies if enemy.visible)))
+            self.render_elements(enemy for enemy in game.enemies if enemy.visible)
             self.render_elements(game.effects)
             self.render_elements(chain(game.players_bullets,
                                        game.lasers_sprites(),
--- a/pytouhou/ui/gamerunner.py
+++ b/pytouhou/ui/gamerunner.py
@@ -168,7 +168,7 @@ class GameRunner(pyglet.window.Window, G
         gluOrtho2D(0., float(self.width), float(self.height), 0.)
         glViewport(0, 0, self.width, self.height)
 
-        items = [item for item in interface.items if item._anmrunner and item._anmrunner._running]
+        items = [item for item in interface.items if item.anmrunner and item.anmrunner.running]
         labels = interface.labels
         if items:
             # Force rendering of labels
@@ -178,7 +178,7 @@ class GameRunner(pyglet.window.Window, G
         else:
             self.render_elements(chain(*(label.objects()
                                             for label in labels.itervalues()
-                                                if label._changed)))
+                                                if label.changed)))
         for label in interface.labels.itervalues():
-            label._changed = False
+            label.changed = False
 
--- a/pytouhou/ui/renderer.pyx
+++ b/pytouhou/ui/renderer.pyx
@@ -50,7 +50,7 @@ cdef class Renderer:
             if nb_vertices >= MAX_ELEMENTS - 4:
                 break
 
-            sprite = element._sprite
+            sprite = element.sprite
             if sprite and sprite.visible:
                 ox, oy = element.x, element.y
                 key, (vertices, uvs, colors) = get_sprite_rendering_data(sprite)
--- a/pytouhou/ui/sprite.pyx
+++ b/pytouhou/ui/sprite.pyx
@@ -21,7 +21,7 @@ from pytouhou.utils.matrix cimport Matri
 cpdef object get_sprite_rendering_data(object sprite):
     cdef Matrix vertmat
 
-    if not sprite._changed:
+    if not sprite.changed:
         return sprite._rendering_data
 
     vertmat = Matrix([[-.5,     .5,     .5,    -.5],
@@ -70,7 +70,7 @@ cpdef object get_sprite_rendering_data(o
     r, g, b = sprite.color
     values = ((x1, y1, z1), (x2, y2, z2), (x3, y3, z3), (x4, y4, z4)), uvs, [r, g, b, sprite.alpha] * 4
     sprite._rendering_data = key, values
-    sprite._changed = False
+    sprite.changed = False
 
     return sprite._rendering_data
 
--- a/pytouhou/vm/anmrunner.py
+++ b/pytouhou/vm/anmrunner.py
@@ -23,7 +23,7 @@ logger = get_logger(__name__)
 
 class ANMRunner(object):
     __metaclass__ = MetaRegistry
-    __slots__ = ('_anm_wrapper', '_sprite', '_running',
+    __slots__ = ('_anm_wrapper', '_sprite', 'running',
                  'sprite_index_offset',
                  'script', 'instruction_pointer', 'frame',
                  'waiting')
@@ -32,7 +32,7 @@ class ANMRunner(object):
     def __init__(self, anm_wrapper, script_id, sprite, sprite_index_offset=0):
         self._anm_wrapper = anm_wrapper
         self._sprite = sprite
-        self._running = True
+        self.running = True
         self.waiting = False
 
         anm, self.script = anm_wrapper.get_script(script_id)
@@ -56,12 +56,12 @@ class ANMRunner(object):
 
 
     def run_frame(self):
-        if not self._running:
+        if not self.running:
             return False
 
         sprite = self._sprite
 
-        while self._running and not self.waiting:
+        while self.running and not self.waiting:
             frame, opcode, args = self.script[self.instruction_pointer]
 
             if frame > self.frame:
@@ -76,7 +76,7 @@ class ANMRunner(object):
                     logger.warn('unhandled opcode %d (args: %r)', opcode, args)
                 else:
                     callback(self, *args)
-                    sprite._changed = True
+                    sprite.changed = True
 
         if not self.waiting:
             self.frame += 1
@@ -88,36 +88,36 @@ class ANMRunner(object):
             ax, ay, az = sprite.rotations_3d
             sax, say, saz = sprite.rotations_speed_3d
             sprite.rotations_3d = ax + sax, ay + say, az + saz
-            sprite._changed = True
+            sprite.changed = True
 
         if sprite.scale_speed != (0., 0.):
             rx, ry = sprite.rescale
             rsx, rsy = sprite.scale_speed
             sprite.rescale = rx + rsx, ry + rsy
-            sprite._changed = True
+            sprite.changed = True
 
         if sprite.fade_interpolator:
             sprite.fade_interpolator.update(sprite.frame)
             sprite.alpha = int(sprite.fade_interpolator.values[0])
-            sprite._changed = True
+            sprite.changed = True
 
         if sprite.scale_interpolator:
             sprite.scale_interpolator.update(sprite.frame)
             sprite.rescale = sprite.scale_interpolator.values
-            sprite._changed = True
+            sprite.changed = True
 
         if sprite.offset_interpolator:
             sprite.offset_interpolator.update(sprite.frame)
             sprite.dest_offset = sprite.offset_interpolator.values
-            sprite._changed = True
+            sprite.changed = True
 
-        return self._running
+        return self.running
 
 
     @instruction(0)
     def remove(self):
-        self._sprite._removed = True
-        self._running = False
+        self._sprite.removed = True
+        self.running = False
 
 
     @instruction(1)
@@ -185,7 +185,7 @@ class ANMRunner(object):
 
     @instruction(15)
     def keep_still(self):
-        self._running = False
+        self.running = False
 
     @instruction(16)
     def load_random_sprite(self, min_idx, amp):
--- a/pytouhou/vm/eclrunner.py
+++ b/pytouhou/vm/eclrunner.py
@@ -164,10 +164,10 @@ class ECLRunner(object):
             enm.die_anim()
 
             if death_flags < 4:
-                if enm._bonus_dropped > -1:
+                if enm.bonus_dropped > -1:
                     enm.drop_particles(7, 0)
-                    self._game.drop_bonus(enm.x, enm.y, enm._bonus_dropped)
-                elif enm._bonus_dropped == -1:
+                    self._game.drop_bonus(enm.x, enm.y, enm.bonus_dropped)
+                elif enm.bonus_dropped == -1:
                     if self._game.deaths_count % 3 == 0:
                         enm.drop_particles(10, 0)
                         self._game.drop_bonus(enm.x, enm.y, self._game.bonus_list[self._game.next_bonus])
@@ -179,7 +179,7 @@ class ECLRunner(object):
                     enm.drop_particles(4, 0)
 
                 if death_flags == 0:
-                    enm._removed = True
+                    enm.removed = True
                     return
 
                 if death_flags == 1:
@@ -214,7 +214,7 @@ class ECLRunner(object):
 
     def run_iteration(self):
         # First, if enemy is dead, return
-        if self._enemy._removed:
+        if self._enemy.removed:
             return False
 
         # Then, check for callbacks
@@ -309,7 +309,7 @@ class ECLRunner(object):
     @instruction(1)
     def destroy(self, arg):
         #TODO: arg?
-        self._enemy._removed = True
+        self._enemy.removed = True
 
 
     @instruction(2)
@@ -1103,17 +1103,17 @@ class ECLRunner(object):
 
     @instruction(128)
     def interrupt(self, event):
-        self._enemy._anmrunner.interrupt(event)
+        self._enemy.anmrunner.interrupt(event)
 
 
     @instruction(129)
     def interrupt_aux(self, number, event):
-        self._enemy.aux_anm[number]._anmrunner.interrupt(event)
+        self._enemy.aux_anm[number].anmrunner.interrupt(event)
 
 
     @instruction(132)
     def set_visible(self, value):
-        self._enemy._visible = not bool(value)
+        self._enemy.visible = not bool(value)
 
 
     @instruction(131)