예제 #1
0
 def _process(self):
     printf("_flush_delay\n")
     _flush_delay()
     printf("about to call process_event\n")
     pgeif.process_event()
     printf("find out which event\n")
     if self._type == frame_event:
         cData = pgeif.get_cbuf()
         printf("cData len = %d\n", len(cData))
         self._set_colour_contents(cData, len(cData))
         fData = pgeif.get_fbuf()
         printf("fData len = %d\n", len(fData))
         self._set_frame_contents(fData, len(fData))
         draw_frame(self._cData, self._clength, self._fData, self._flength)
         pgeif.empty_fbuffer()
         pgeif.empty_cbuffer()
     elif self._type == collision_event:
         printf("collision event seen, in %f seconds\n", self.__etime)
         # pgeif.skip_until (self.__etime)
         collision(self._between())
예제 #2
0
def runbatch (t):
    if t < 0.0:
        t = 30.0
    debugf ("runbatch (%f)\n", t)
    pgeif.check_objects ()
    cData = pgeif.get_cbuf ()
    fData = pgeif.get_fbuf ()
    draw_frame (cData, len (cData), fData, len (fData))
    pgeif.empty_fbuffer ()
    pgeif.empty_cbuffer ()
    nev = _get_next_event ()
    acc = 0.0
    while acc+nev._get_time () < t:
        old = acc
        acc = acc + nev._get_time ()
        delay (nev._get_time ())
        if int(acc) != int(old):
            printf ("%d/%d seconds completed %d%%\n", int (acc), int (t), int (acc*100.0/t))
            # printf ("time %f out of %f seconds\n", acc, t)
        _process (nev)
        nev = _get_next_event ()
예제 #3
0
 def _process (self):
     printf ("_flush_delay\n")
     _flush_delay ()
     printf ("about to call process_event\n")
     pgeif.process_event ();
     printf ("find out which event\n")
     if self._type == frame_event:
         cData = pgeif.get_cbuf ()
         printf ("cData len = %d\n", len (cData))
         self._set_colour_contents (cData, len (cData))
         fData = pgeif.get_fbuf ()
         printf ("fData len = %d\n", len (fData))
         self._set_frame_contents (fData, len (fData))
         draw_frame (self._cData, self._clength,
                     self._fData, self._flength)
         pgeif.empty_fbuffer ()
         pgeif.empty_cbuffer ()
     elif self._type == collision_event:
         printf ("collision event seen, in %f seconds\n", self.__etime)
         # pgeif.skip_until (self.__etime)
         collision (self._between ())
예제 #4
0
def runbatch(t):
    if t < 0.0:
        t = 30.0
    debugf("runbatch (%f)\n", t)
    cData = pgeif.get_cbuf()
    fData = pgeif.get_fbuf()
    draw_frame(cData, len(cData), fData, len(fData))
    pgeif.empty_fbuffer()
    pgeif.empty_cbuffer()
    nev = _get_next_event()
    acc = 0.0
    while acc + nev._get_time() < t:
        old = acc
        acc = acc + nev._get_time()
        delay(nev._get_time())
        if int(acc) != int(old):
            printf("%d/%d seconds completed %d%%\n", int(acc), int(t),
                   int(acc * 100.0 / t))
            # printf ("time %f out of %f seconds\n", acc, t)
        _process(nev)
        nev = _get_next_event()
예제 #5
0
def runpy(t=-1, ep=None):
    pgeif.use_time_delay(False)
    cData = pgeif.get_cbuf()
    fData = pgeif.get_fbuf()
    draw_frame(cData, len(cData), fData, len(fData))
    pgeif.empty_fbuffer()
    pgeif.empty_cbuffer()
    nev = _post_event(_get_next_event())
    fin = _post_event(_finish_event(t))
    while True:
        for e in pygame.event.get():
            if e.type == USEREVENT:
                if e.pge_event == fin:
                    return
                else:
                    _process(e.pge_event)
                    nev = _post_event(_get_next_event())
            else:
                if ep != None:
                    if nev._get_time() >= cur_time():
                        pgeif.advance_time(cur_time())
                    ep(e)
예제 #6
0
def runpy (t=-1, ep=None):
    pgeif.use_time_delay (False)
    cData = pgeif.get_cbuf ()
    fData = pgeif.get_fbuf ()
    draw_frame (cData, len (cData), fData, len (fData))
    pgeif.empty_fbuffer ()
    pgeif.empty_cbuffer ()
    ev = _get_next_event ()
    nev = _post_event (ev, ev._get_time ())
    fin = _post_event (_finish_event (t), t)
    while True:
        for e in pygame.event.get():
            if e.type == USEREVENT:
                if e.pge_event == fin:
                    return
                else:
                    _process (e.pge_event)
                    ev = _get_next_event ()
                    nev = _post_event (ev, ev._get_time ())
            else:
                if ep != None:
                    if nev._get_time () >= cur_time ():
                        pgeif.advance_time (cur_time ())
                    ep (e)