• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python clock.set_fps_limit函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyglet.clock.set_fps_limit函数的典型用法代码示例。如果您正苦于以下问题:Python set_fps_limit函数的具体用法?Python set_fps_limit怎么用?Python set_fps_limit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了set_fps_limit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_sprite

    def test_sprite(self):
        w = pyglet.window.Window(width=320, height=320)

        image = Image2d.load(ball_png)
        ball1 = BouncySprite(0, 0, 64, 64, image, properties=dict(dx=10, dy=5))
        ball2 = BouncySprite(288, 0, 64, 64, image, properties=dict(dx=-10, dy=5))
        view = FlatView(0, 0, 320, 320, sprites=[ball1, ball2])
        view.fx, view.fy = 160, 160

        clock.set_fps_limit(60)
        e = TintEffect((0.5, 1, 0.5, 1))
        while not w.has_exit:
            clock.tick()
            w.dispatch_events()

            ball1.update()
            ball2.update()
            if ball1.overlaps(ball2):
                if "overlap" not in ball2.properties:
                    ball2.properties["overlap"] = e
                    ball2.add_effect(e)
            elif "overlap" in ball2.properties:
                ball2.remove_effect(e)
                del ball2.properties["overlap"]

            view.clear()
            view.draw()
            w.flip()

        w.close()
开发者ID:odyaka341,项目名称:pyglet,代码行数:30,代码来源:SPRITE_OVERLAP.py


示例2: on_key_press

def on_key_press(symbol, modifiers):
    global evolving, fps_limit, grid, show_help
    if show_help:
        show_help = False
        return

    if symbol == key.H:
        # show help screen
        show_help = True
    if symbol == key.SPACE:
        # toggle evolving
        evolving = not evolving
    if symbol == key.R:
        # reseed grid
        seed_grid()
    if symbol == key.C:
        # clear grid
        grid = [[(0,0)]*50 for i in range(50)]
    if symbol == key.UP:
        fps_limit += 2
        if fps_limit > 40: fps_limit = 40
        clock.set_fps_limit(fps_limit)
    if symbol == key.DOWN:
        fps_limit -= 2
        if fps_limit < 2: fps_limit = 2
        clock.set_fps_limit(fps_limit)
开发者ID:gumuz,项目名称:lifegame2d,代码行数:26,代码来源:lifegame2d.py


示例3: __init__

    def __init__(self):
        pyglet.window.Window.__init__(self,vsync = True,fullscreen=True)
        self.set_mouse_visible(False)
        self.bgcolor=bgcolor
        self.size_x,self.size_y=self.get_display_size()
        self.center= self.size_x*0.5,self.size_y*0.5
        self.paused=False
        self.camera=Camera((self.center), 0.1)
        self.key_actions = {
            key.ESCAPE: lambda: exit(),
            key.PAGEUP: lambda: self.camera.zoom(2),
            key.PAGEDOWN: lambda: self.camera.zoom(0.5),
            key.LEFT: lambda: self.camera.pan(self.camera.scale, -1.5708),
            key.RIGHT: lambda: self.camera.pan(self.camera.scale, 1.5708),
            key.DOWN: lambda: self.camera.pan(self.camera.scale, 3.1416),
            key.UP: lambda: self.camera.pan(self.camera.scale, 0),
            key.COMMA: lambda: self.camera.tilt(-1),
            key.PERIOD: lambda: self.camera.tilt(+1),
            key.P : lambda: self.toggle_pause(),
            }


        self.gl_setup()
        # schedule the update function at 'fps' times per second
        clock.schedule_interval(self.update, 1.0/100.0)
        clock.set_fps_limit(max_fps)
开发者ID:msarch,项目名称:py,代码行数:26,代码来源:pygland.py


示例4: main

def main():
    win = pyglet.window.Window( width=800, height=600 )

    anims = []

    @win.event
    def on_key_press(symbol, modifiers):
        #print 'Flipping', anims
        for anim in anims:
            anim.flip()

    anims.append( Anim('subWalkNorm', 5) )
    anims.append( BeerThrowAnim() )

    while not win.has_exit:
        done = False
        clock.set_fps_limit(FRAMES_PER_SECOND)

        while not done:
            timeChange = clock.tick()

            win.dispatch_events()
            for anim in anims:
                anim.update( timeChange )

            win.clear()
            if done or win.has_exit:
                break

            for anim in anims:
                anim.draw()

            win.flip()
开发者ID:avuserow,项目名称:yoyobrawlah,代码行数:33,代码来源:animation.py


示例5: instructionScreen

def instructionScreen(windowSurface, WWIDTH, FRAMES, background_image, background_position):

    while True:

        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()

        windowSurface.blit(background_image, background_position)
        
        displayText(windowSurface, 128, WWIDTH / 2, 125, 'MEGA', RED)
        displayText(windowSurface, 128, WWIDTH / 2, 275, 'JUMP!', GREEN)
        displayText(windowSurface, 20, WWIDTH / 2, 400, 'Space to jump (+ down arrow for small jump, M for MegaJump)', GREEN)
        displayText(windowSurface, 20, WWIDTH / 2, 450, 'Left & Right arrows to move (+ up arrow to move faster)', GREEN)
        displayText(windowSurface, 20, WWIDTH / 2, 500, 'Q to quit, R to reset', GREEN)
        displayText(windowSurface, 20, WWIDTH / 2, 550, 'Only 1 MegaJump per game!', RED)
        displayText(windowSurface, 20, WWIDTH / 2, 600, 'Press ESC to return to main screen', GREEN)

        pygame.draw.circle(windowSurface, GOLD, (510, 550), 10, 0)

        if pygame.key.get_pressed()[K_ESCAPE]:
            return

        pygame.display.flip()

        clock.set_fps_limit(FRAMES)
        clock.tick()
开发者ID:axemaster1974,项目名称:MegaJump2,代码行数:28,代码来源:gameFunc.py


示例6: __init__

    def __init__(self, fullscreen=False,
                 screen=None,
                 width=None, height=None,
                 visible=False, vsync=False, fps=60,
                 show_fps=False):
        platform = get_platform()
        display = platform.get_default_display()
        screens = display.get_screens()
        screen=screens[screen]
        self.window = MyWindow(fullscreen=fullscreen, screen=screen,
            width=width, height=height, visible=visible,
            vsync=vsync
        )
        # glClearColor(0., 0., 0., 0.0)
        # glEnable(GL_BLEND)
        # glEnable(GL_LINE_SMOOTH)
        # glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
        self.clockDisplay = clock.ClockDisplay(color=(1., 1., 1., .8)) if show_fps \
                            else None
        self.paused = False
        clock.set_fps_limit(fps)

        self.window.on_draw = self.on_draw
        self.window.on_key_press = self.on_key_press
        self.window.on_mouse_drag = self.on_mouse_drag
        self.window.on_mouse_press = self.on_mouse_press
开发者ID:naymen,项目名称:MELA,代码行数:26,代码来源:application.py


示例7: __init__

    def __init__(self, window):
        self.win = window
        self.world = World()
        self.camera = Camera(self.win, zoom=100.0)
        self.hud = Hud(self.win)

        clock.set_fps_limit(settings.WINDOW['framerate'])
开发者ID:purplemass,项目名称:python-slideshow,代码行数:7,代码来源:polygon.py


示例8: __init__

 def __init__(self, *args, **kwargs):
   super(MainWindow, self).__init__(*args, **kwargs)
   self.keys = window.key.KeyStateHandler()
   self.push_handlers(self.keys)
   # self.set_exclusive_mouse()
   self.width, self.height, self.rat3d, self.ratex = 640, 480, 1.05, 0.5
   self.zoom, self.expand, self.mapping, self.blend = 0, 0, 0, 1
   self.fgc, self.bgc = (1.0, 1.0, 1.0, 0.9), (0.1, 0.1, 0.1, 0.1)
   self.loadfgc, self.loadbgc = (0.4, 0.2, 0.4, 0.3), (0.6, 0.3, 0.6, 0.9)
   self.instfgc, self.instbgc = (0.1, 0.1, 0.5, 0.9), (0.5, 0.9, 0.9, 0.8)
   self.instbkwidth, self.instbkheight = 480, 400
   bmplen = (self.instbkwidth / 8) * self.instbkheight
   self.instbkbmp = (ctypes.c_ubyte * bmplen)(*([255] * bmplen))
   self.ticktimer, self.tick, self.insttimer, self.inst = 0.5, 0.0, 30, 1
   self.printing, self.solver = 1, deque()
   self.stat = [None, 0, Queue.Queue(512)] # (key(1-9), direc), count, queue
   self.cmax, self.tanim = 18, [6, 3, 1, 3] # frames in rotate moving, speeds
   self.tcos, self.tsin = [1.0] * (self.cmax + 1), [0.0] * (self.cmax + 1)
   for i in xrange(1, self.cmax):
     t = i * math.pi / (2.0 * self.cmax) # 0 < t < pi/2
     self.tcos[i], self.tsin[i] = math.cos(t), math.sin(t)
   self.tcos[self.cmax], self.tsin[self.cmax] = 0.0, 1.0 # pi/2 regulation
   self.InitRot()
   self.InitAxis()
   self.InitGL(self.width, self.height)
   self.textures = [None] * (len(self.ary_norm) * 2 + 1 + len(TEXIMG_CHAR))
   self.loading, self.dat = 0, [('', 0, 0)] * len(self.textures)
   resource.add_font(FONT_FILE)
   self.font = font.load(FONT_FACE, 20)
   self.fontcolor = (0.5, 0.8, 0.5, 0.9)
   self.fps_display = clock.ClockDisplay(font=self.font, color=self.fontcolor)
   self.fps_pos = (-60.0, 30.0, -60.0)
   clock.set_fps_limit(60)
   clock.schedule_interval(self.update, 1.0 / 60.0)
开发者ID:HatsuneMiku,项目名称:HatsuneMiku,代码行数:34,代码来源:rcube.py


示例9: test_sprite

    def test_sprite(self):
        w = pyglet.window.Window(width=320, height=320)

        image = Image2d.load(ball_png)
        ball = Sprite(0, 0, 64, 64, image)
        view = FlatView(0, 0, 320, 320, sprites=[ball])

        w.push_handlers(view.camera)

        dx, dy = (10, 5)

        clock.set_fps_limit(30)
        while not w.has_exit:
            clock.tick()
            w.dispatch_events()

            # move, check bounds
            ball.x += dx; ball.y += dy
            if ball.left < 0: ball.left = 0; dx = -dx
            elif ball.right > w.width: ball.right = w.width; dx = -dx
            if ball.bottom < 0: ball.bottom = 0; dy = -dy
            elif ball.top > w.height: ball.top = w.height; dy = -dy

            # keep our focus in the middle of the window
            view.fx = w.width/2
            view.fy = w.height/2

            view.clear()
            view.draw()
            w.flip()

        w.close()
开发者ID:DatRollingStone,项目名称:nwidget,代码行数:32,代码来源:FLAT_SPRITE.py


示例10: test_limit_fps

    def test_limit_fps(self):
        """
        Test that the clock effectively limits the
        frames per second to 60 Hz when set to.

        Because the fps are bounded, we expect a small error (1%)
        from the expected value.
        """
        ticks = 20
        fps_limit = 60
        expected_delta_time = ticks*1./fps_limit

        clock.set_fps_limit(fps_limit)

        t1 = time.time()
        # Initializes the timer state.
        clock.tick()
        for i in range(ticks):
            clock.tick()
        t2 = time.time()

        computed_time_delta = t2 - t1

        self.assertAlmostEqual(computed_time_delta,
                               expected_delta_time,
                               delta=0.01*expected_delta_time)
开发者ID:DiscoBizzle,项目名称:Ghost-Simulator,代码行数:26,代码来源:FPS.py


示例11: main_loop

 def main_loop(self):
     clock.set_fps_limit(self.update_fps)
     while not self.has_exit:
         self.dispatch_events()
         self.update_cells()
         self.draw_grid()
         clock.tick()
         self.flip()
开发者ID:reuteran,项目名称:game-of-life,代码行数:8,代码来源:grid.py


示例12: __init__

    def __init__(self):
        self.win = pyglet.window.Window(resizable=True, vsync=True)
        self.camera = Camera(self.win, zoom=10)
        self.setup_GL()
        self._setup_win_handlers()

        self.network = Network()
        self.world = World(self.network)
        self.hud = Hud(self)

        clock.set_fps_limit(60)
开发者ID:jakebarnwell,项目名称:PythonGenerator,代码行数:11,代码来源:scene.py


示例13: __init__

    def __init__(self):
        self.world = World()
        self.win = pyglet.window.Window(fullscreen=True, vsync=True)

        for i in dir(self):
            if i.startswith('on_'):
                setattr(self.win, i, getattr(self, i))

        self.camera = Camera(self.win, zoom=100.0)
        self.hud = Hud(self.win)
        clock.set_fps_limit(60)
开发者ID:jon1012,项目名称:babytux,代码行数:11,代码来源:app.py


示例14: test_fps_limit

    def test_fps_limit(self):
        clock.set_default(clock.Clock())
        clock.set_fps_limit(20)
        self.assertTrue(clock.get_fps() == 0)

        t1 = time.time()
        clock.tick() # One to get it going
        for i in range(20):
            clock.tick()
        t2 = time.time()
        self.assertTrue(abs((t2 - t1) - 1.) < 0.05)
开发者ID:DatRollingStone,项目名称:nwidget,代码行数:11,代码来源:FPS_LIMIT.py


示例15: test_multisample

 def test_multisample(self):
     self.set_window()
     self.angle = 0
     clock.set_fps_limit(30)
     while not self.win.has_exit:
         dt = clock.tick()
         self.angle += dt
         
         self.render()
         self.win.flip()
         self.win.dispatch_events()
     self.win.close()
开发者ID:LaneLutgen,项目名称:CSCI338-BinPacking,代码行数:12,代码来源:WINDOW_MULTISAMPLE.py


示例16: savedGameScreen

def savedGameScreen(savedGames, windowSurface, WWIDTH, WHEIGHT, FRAMES, background_image, background_position):        

    time.sleep(0.3)
    
    while True:

        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()

        windowSurface.blit(background_image, background_position)
        displayTextLJ(windowSurface, 36, 50, 50, 'Saved Games List', RED)
        displayTextLJ(windowSurface, 24, 50, 100, "Name", RED)
        displayTextLJ(windowSurface, 24, 200, 100, "Difficulty", RED)
        displayTextLJ(windowSurface, 24, 350, 100, "Platforms", RED)
        displayTextLJ(windowSurface, 24, 500, 100, "Record", RED)
        
        displayTextLJ(windowSurface, 20, 50, 550, 'Press number to select game or D plus number to delete game', RED)
        displayTextLJ(windowSurface, 20, 50, 600, 'Escape to return to previous screen', RED)
        
        count = 1
        for game in savedGames:
            displayTextLJ(windowSurface, 20, 50, 100 + (count * 30), str(count) + ". " + game['name'], GREEN)
            displayTextLJ(windowSurface, 20, 200, 100 + (count * 30), game['difficulty'], GREEN)
            displayTextLJ(windowSurface, 20, 350, 100 + (count * 30), game['pnumber'], GREEN)
            if game['difficulty'] == "INSANE":
                displayTextLJ(windowSurface, 20, 500, 100 + (count * 30), "Score: " + game['score'], GREEN)
            else:
                displayTime(windowSurface, int(game['record']), 500, 100 + (count * 30), GREEN, 20, "True")
            count += 1

        if not pygame.key.get_pressed()[ord('d')]:
            for i in range(len(savedGames)):
                if pygame.key.get_pressed()[ord(str(i+1))]:
                    return savedGames[i], i

        if pygame.key.get_pressed()[ord('d')]:
            for i in range(len(savedGames)):
                if pygame.key.get_pressed()[ord(str(i+1))]:
                     del savedGames[i]
                     saveGames(windowSurface, WWIDTH, WHEIGHT, None, savedGames, None, "Delete")
                     time.sleep(0.5)
                     break
                       
        if pygame.key.get_pressed()[K_ESCAPE]:
            return None, None

        pygame.display.flip()

        clock.set_fps_limit(FRAMES)
        clock.tick()
开发者ID:axemaster1974,项目名称:MegaJump2,代码行数:52,代码来源:gameFunc.py


示例17: run_test

 def run_test(self):
     clock.set_fps_limit(30)
     while not self.w.has_exit:
         clock.tick()
         self.w.dispatch_events()
         self.view.fx += (self.keyboard[key.RIGHT] - self.keyboard[key.LEFT]) * 5
         self.view.fy += (self.keyboard[key.UP] - self.keyboard[key.DOWN]) * 5
         if self.marker is not None:
             self.marker.x = self.view.fx
             self.marker.y = self.view.fy
         self.view.clear()
         self.view.draw()
         self.w.flip()
     self.w.close()
开发者ID:DatRollingStone,项目名称:nwidget,代码行数:14,代码来源:render_base.py


示例18: main_loop

 def main_loop(self):
     clock.set_fps_limit(30)
     clock.schedule_interval(self.animate_bird, 0.01)
     
     while not self.has_exit:
         self.dispatch_events()
         self.clear()
     
         self.update()
         self.draw()
     
         #Tick the clock
         clock.tick()
         self.flip()
开发者ID:jseutter,项目名称:featherwars,代码行数:14,代码来源:fowl.py


示例19: main

def main():
    title_screen()
    setup_screen()
    join_screen()
    host_screen()
    game_screen()
    end_screen()

    manager.set_media(mp)
    manager.add_widget(my_bg)
    game_window.push_handlers(manager)
    # Pyglet Settings
    schedule_interval(update, 1 / 120.0)
    set_fps_limit(120)
    run()
开发者ID:nmcalabroso,项目名称:Push,代码行数:15,代码来源:client_push.py


示例20: __init__

	def __init__(self):
		self.Width, self.Height = 640, 480
		self.Window = BannerWindow(self.Width, self.Height)
		self.Window.set_exclusive_mouse(False)
		self.Brlyt = None
		
		glClearColor(0.0, 0.0, 0.0, 0.0)
		glClearDepth(1.0)
		glDepthFunc(GL_LEQUAL)
		glEnable(GL_DEPTH_TEST)
		
		glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
		glEnable(GL_BLEND)
		
		glEnable(GL_TEXTURE_2D)
		
		clock.set_fps_limit(60)
开发者ID:HACKERCHANNEL,项目名称:benzin,代码行数:17,代码来源:Alameda.py



注:本文中的pyglet.clock.set_fps_limit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python clock.tick函数代码示例发布时间:2022-05-25
下一篇:
Python clock.schedule_once函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap