class Slide(UserState): def __init__(self, app, hand, time=max_slide_wait, arrow=None): UserState.__init__(self, app, hand.user) self.hand = hand self.start_time = clock() self.time = time base.slide(hand.side_sign) self.arrow = arrow if not self.arrow: self.arrow = Arrow(self.app, hand.user, hand.side) self.arrow.play_trigger() self.arrow.update(base.nui.users) print 'time', time self.timer(time, self.timeout) def hand_move(self, hand): if hand.side == self.hand.side and not self.arrow.is_playing: max_extension = 0.55 pos = hand.positions[-1].x * hand.side_sign time = max(0.0, min(1.0, (pos - hand_trigger) / (max_extension - hand_trigger))) self.time = max_slide_wait - time * (max_slide_wait - min_slide_wait) self.timer(self.time - (clock()-self.start_time), self.timeout) self.arrow.set_time_at_speed(time) self.arrow.update(base.nui.users) UserState.hand_move(self, hand) def hand_in(self, hand): if hand.side != self.hand.side: self.arrow.destroy() self.next_state(Thumbnails(self.app, self.hand.user)) def hand_out(self, hand): if hand.side == self.hand.side: self.arrow.destroy() self.next_state(Start(self.app)) def lost_user(self): self.arrow.destroy() def timeout(self): self.next_state(Slide(self.app, self.hand, self.time, self.arrow))