Ejemplo n.º 1
0
 def _body_moving_step(self, body):
     sp = float(S.player['body_moving_speed'])
     map = self.manager.map
     next_pos = self.get_next_pos()
     if self.must_die or next_pos is None:
         yield ret(False)
     shift = next_pos[1] - self.pos[1], next_pos[0] - self.pos[0]
     # new body pos after rotation but berfore moving
     new_bpos = self.pos[0] - shift[1], self.pos[1] - shift[0]
     if body.poses[0] != new_bpos:
         bpath = map.get_radial_path(self.pos, body.poses[0],
                                     new_bpos, self.walk_pred, 2)
         if not bpath:
             yield ret(False)
         prev_bpos = body.poses[0]
         for cur_bpos in bpath:
             if not map.get_radial_path(self.pos,
                                        prev_bpos,
                                        cur_bpos,
                                        self.walk_pred,
                                        2):
                 break
             #cur_bpos is pos to which player should rotate
             yield self._rotate_to(cur_bpos, speed=sp)
             prev_bpos = cur_bpos
             body.update_poses()
         if cur_bpos != new_bpos:
             yield ret(False)
     if not map.check_square(self.pos, next_pos, self.walk_pred):
         yield ret(False)
     if self.get_next_pos() is None:
         yield ret(False)
     dur = 1.4 / sp if all(shift) else 1.0 / sp
     interval = LerpPosInterval(self.node, dur, next_pos + (0,))
     map.block(next_pos)
     self.walking = True
     yield interval
     self.pos = next_pos
     map.unblock(self.pos)
     self.walking = False
     body.update_poses()
Ejemplo n.º 2
0
 def _falling(self):
     actor = self.actor
     ds = S.ch_anim['death_speed']
     dr = (S.ch_anim['forward_death_range'] if self.fall_forward
                             else S.ch_anim['backward_death_range'])
     anim_interval = actor.actorInterval(
         'anim', playRate=ds,
         startFrame=dr[0], endFrame=dr[1]
     )
     anim_interval.start()
     actor.setTransparency(True)
     interval = LerpColorScaleInterval(actor, 1 / ds / 7, (1, 1, 1, 0))
     yield interval
     yield ret(anim_interval)