Example #1
0
File: engine.py Project: msarch/py
def main():
        # schedule pyglet  loop at max framerate
        # and the tick function at more than fps
        # frame / time driven loop
    options = {
    'DEBUG': 1,
    'PREVIEW_SIZE': (800, 600),
    'BGCOLOR': (0.95, 0.95, 0.95, 0),  # background
    'FPS': 60,  # display max framerate
    'PicPS': 25,  # images per second for movie export
    'MODE': 'PREVIEW',  # options are: 'FULL'; 'PREVIEW'; 'EXPORT'
    'DURATION' : 3,
    'SCENE_FOLDER' : 'scene',
    }

    engine = Engine(**options)

    #---run loop options-------------------------------------------------------
    if  engine.MODE in ('FULL','PREVIEW'):
        clock.schedule_interval(engine.frame_paint,1.0/engine.FPS)
        clock.schedule_interval_soft(engine.tick, 1.0/(1.0*engine.FPS))
    elif engine.MODE == 'EXPORT': # export loop
        # try (soft) to run export method at final anim speed,
        clock.schedule_interval_soft(engine.export_loop,1.0/engine.PicPS)
        # while (soft) run the preview at good rate
        #clock.schedule_interval_soft(self.frame_, 1.0/self.FPS,scene)

    pyglet.app.run()
Example #2
0
File: animate.py Project: msarch/py
def animate(field):
    e = Engine(field,fullscreen=True)
    # normal loop : run the preview at good rate
    clock.schedule_interval(e.paint_a_frame, FRAMERATE)
    # and try (soft) to run anim at same speed
    clock.schedule_interval_soft(e.tick, FRAMERATE)
    pyglet.app.run()
Example #3
0
    def setup_pyglet(self):
        """Configure Pyglet attributes.

        """
        self.window = window.Window(visible=False, caption=CAPTION,
                                    fullscreen=config.fullscreen)
        clock.schedule_interval_soft(self.tick, 1.0 / TICK_RATE)
        clock.schedule_interval_soft(self.update, 1.0 / UPDATE_RATE)
Example #4
0
File: gui.py Project: msarch/py
 def run(self):
     if MODE in ('FULLSCREEN', 'PREVIEW'):  # normal loop
         # run the preview at good rate
         clock.schedule_interval(self.frame_paint, FRAMERATE)
         # and try (soft) to run export method at final anim speed,
         clock.schedule_interval_soft(self.tick, FRAMERATE)
     elif MODE == 'EXPORT':  # trigger the export loop
         clock.schedule_interval_soft(self.pic_export_loop, MOVIE_FRAMERATE)
     pyglet.app.run()
Example #5
0
 def _update_schedule(self):
     clock.unschedule(self.dispatch_events)
     if self._playing and self._sources:
         interval = 1000.0
         if self._sources[0].video_format:
             interval = min(interval, 1 / 24.0)
         if self._audio:
             interval = min(interval, self._audio.UPDATE_PERIOD)
         clock.schedule_interval_soft(self.dispatch_events, interval)
Example #6
0
    def setup_pyglet(self):
        """Configure Pyglet attributes.

        """
        self.window = window.Window(visible=False, caption=CAPTION,
                fullscreen=config.fullscreen)
        clock.schedule_interval_soft(self.tick, 1.0 / TICK_RATE)
        clock.schedule_interval_soft(self.update, 1.0 / UPDATE_RATE)
        self.window.set_mouse_cursor(window.ImageMouseCursor(data.load_image("cursor.png"), 4, 60))
Example #7
0
 def run(self):
     if self.mode in ('FULL', 'PREVIEW'):  # normal loop
         # run the preview at good rate
         clock.schedule_interval(self.frame_paint, self.framerate)
         # and try (soft) to run export method at final anim speed,
         clock.schedule_interval_soft(self.tick, self.framerate)
     elif self.mode == 'EXPORT':  # trigger the export loop
         clock.schedule_interval_soft(self.pic_export_loop, movie_framerate)
     pyglet.app.run()
Example #8
0
    def setup_pyglet(self):
        """Configure Pyglet attributes.

        """
        self.window = window.Window(width=800, height=600, visible=False, caption="Ookoobah", resizable=True, fullscreen=False)
        self.window.set_fullscreen(True)
        self.gui = gui.Manager(self.window)
        clock.schedule_interval_soft(self.tick, 1 / 60)

        sounds.load()
Example #9
0
File: animate.py Project: msarch/py
def export(field,duration):
    abspath = os.path.abspath(__file__)
    parent = os.path.dirname(os.path.dirname(abspath))
    imgdir = os.path.join (parent, 'out')
    try:
        os.makedirs(imgdir)
    except OSError:
        pass
    os.chdir(imgdir)
    field.duration=duration
    e = Engine(field,fullscreen=False)
    clock.schedule_interval_soft(e.pic_export_loop, MOVIE_FRAMERATE)
    pyglet.app.run()
Example #10
0
 def start_game(self, controller, player_name = "Samus", host="localhost", game_name = "Deathtroid"):
   self.menu = None
   #self.init_gl()
   if controller == "server" or controller == "both":
     if self.server == None:
       self.server = server_controller.ServerController(game_name)
     #clock.schedule(self.server.update)
     clock.schedule_interval_soft(self.server.update, 1./30.)
   
   if controller == "client" or controller == "both":
     if self.client == None:
       self.client = client_controller.ClientController(player_name, host)
     clock.schedule(self.client.update)
Example #11
0
File: engine.py Project: msarch/py
def export(duration):
    VIEW.set_size(PREVIEW_SIZE[0], PREVIEW_SIZE[1])
    # @TODO : check if bigger than screen, then set fullscreen
    # or 80% of screen, print error message
    # then set XMAX,YMAX
    abspath = os.path.abspath(__file__)
    parent = os.path.dirname(os.path.dirname(abspath))
    imgdir = os.path.join (parent, 'out')
    try:
        os.makedirs(imgdir)
    except OSError:
        pass
    os.chdir(imgdir)
    clock.schedule_interval_soft(pic_export_loop, MOVIE_FRAMERATE)
    pyglet.app.run()
Example #12
0
File: engine.py Project: msarch/py
    def run(self,scene):
            # schedule pyglet  loop at max framerate
            # and the update function at more than fps
            # frame / time driven loop
        self.scene=scene

        if  self.MODE in ('FULL','PREVIEW'):
            clock.schedule_interval(self.frame_,1.0/self.FPS)
            clock.schedule_interval_soft(self.update, 1.0/(1.0*self.FPS))
        elif self.MODE == 'EXPORT': # export loop
            # try (soft) to run export method at final anim speed,
            clock.schedule_interval_soft(self.export_loop,1.0/self.PicPS)
            # while (soft) run the preview at good rate
            #clock.schedule_interval_soft(self.frame_, 1.0/self.FPS,scene)

        pyglet.app.run()
Example #13
0
File: engine.py Project: msarch/py
    def run(self):
            # schedule pyglet ondraw loop at max framerate
            # and the update function at more than fps
            # frame / time driven loop

        if  self.MODE in ('FULL','PREVIEW'):
            clock.schedule_interval(self.frame_draw,1.0/self.FPS)
            clock.schedule_interval_soft(self.update, 1.0/(1.0*self.FPS))
        elif self.MODE == 'EXPORT': # export loop
            # try to run export method at final anim speed,
            clock.schedule_interval_soft(self.export_loop,1.0/self.PicPS)
            # anyway run preview at good rate
            clock.schedule_interval_soft(self.frame_draw, 1.0/self.FPS)

        pyglet.app.run()
Example #14
0
File: animate.py Project: msarch/py
def export(field):
    e = Engine(field)
    clock.schedule_interval_soft(e.pic_export_loop, MOVIE_FRAMERATE)
    pyglet.app.run()
Example #15
0
 def schedule_update_if_needed(self):
   clock.unschedule(self.update)
   if self._callback or self.entity:
     clock.schedule_interval_soft(self.update, 1./10.)