Esempio n. 1
1
    def run(self):
        times = self.history.keys()
        times.sort()
        start_time = time.clock()
        elapsed_time = 0.0

        for t in times:
            force_exit_event.wait(t-elapsed_time)

            if force_exit_event.isSet():
                break
            event = self.history[t]

            import pygame_run
            pygame_run.post_tutorial_event(self, event)

            elapsed_time = time.clock() - start_time
        # end for

# At this point, either we've been told by the main Archy thread that we need to quit (meaning that the user has probably pressed a key in the middle of the tutorial), or we've run out of events to dispatch.   If the latter is the case, then we need to wait around for the main Archy thread to tell us to quit.

        force_exit_event.wait()

# At this point, our thread has exclusive control of Archy's state, since the main Archy thread is waiting for the force_exit_event event to be cleared.  Therefore, we must be certain to clear this event at the *very end* of this function, and no sooner--lest we give up our exclusive control of Archy's state and throw thread safety out the window.
        self.doOnDone()

        commands.save_and_load.saveState()

        is_running_event.clear()
        force_exit_event.clear()
Esempio n. 2
0
    def run(self):
        times = self.history.keys()
        times.sort()
        start_time = time.clock()
        elapsed_time = 0.0

        for t in times:
            force_exit_event.wait(t - elapsed_time)

            if force_exit_event.isSet():
                break
            event = self.history[t]

            import pygame_run
            pygame_run.post_tutorial_event(self, event)

            elapsed_time = time.clock() - start_time
        # end for


# At this point, either we've been told by the main Archy thread that we need to quit (meaning that the user has probably pressed a key in the middle of the tutorial), or we've run out of events to dispatch.   If the latter is the case, then we need to wait around for the main Archy thread to tell us to quit.

        force_exit_event.wait()

        # At this point, our thread has exclusive control of Archy's state, since the main Archy thread is waiting for the force_exit_event event to be cleared.  Therefore, we must be certain to clear this event at the *very end* of this function, and no sooner--lest we give up our exclusive control of Archy's state and throw thread safety out the window.
        self.doOnDone()

        commands.save_and_load.saveState()

        is_running_event.clear()
        force_exit_event.clear()
Esempio n. 3
0
def stop_tutorial():
    import time
    force_exit_event.set()
    while force_exit_event.isSet():
        time.sleep(0.01)
Esempio n. 4
0
def stop_tutorial():
    import time
    force_exit_event.set()
    while force_exit_event.isSet():
        time.sleep(0.01)