Ejemplo n.º 1
0
 def change_velocity(self, x_change, y_change):
     Key_Direction_Controls.change_velocity(self, x_change, y_change)
     vx, vy = self.owner.velocity
     dir =  None
     if vx > 0:
         if vy > 0:
             dir = "downright_frames"
         elif vy < 0:
             dir = "upright_frames"
         else:
             dir = "right_frames"
     elif vx < 0:
         if vy > 0:
             dir = "downleft_frames"
         elif vy < 0:
             dir = "upleft_frames"
         else:
             dir = "left_frames"
     elif vy > 0:
         dir = "down_frames"
     elif vy < 0:
         dir = "up_frames"
     if self.dir == dir or dir == None:
         return
     self.dir = dir
     self.frames = self.framedict[dir]
     try:
         self.anim_action.abort()
     except:
         pass
     action = Opioid2D.Animate(self.frames, fps=self.fps, 
                      mode=self.modes["Repeat"])
     if self.rotate:
         if self.image_sprite is None:
             self.image_sprite = Opioid2D.Sprite()
             self.image_sprite.attach_to(self.owner)
             self.owner.image = self.frames[0]
             self.owner.alpha = 0
         image_sprite = self.image_sprite
         image_sprite.rotation = -self.owner.rotation
     else:
         image_sprite = self.owner
     self.anim_action = action.do(image_sprite)
Ejemplo n.º 2
0
 def on_added_to_scene(self):
     Key_Direction_Controls.on_added_to_scene(self)
     (Opioid2D.Delay(0) + Opioid2D.CallFunc(self.do_load_frames)).do()
Ejemplo n.º 3
0
 def on_destroy(self):
     Key_Direction_Controls.on_destroy(self)
     Forward_Motion.on_destroy(self)